@phren/cli 0.1.15 → 0.1.16
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/capabilities/cli.js +1 -1
- package/dist/capabilities/mcp.js +1 -1
- package/dist/capabilities/vscode.js +1 -1
- package/dist/capabilities/web-ui.js +1 -1
- package/dist/content/citation.d.ts +4 -0
- package/dist/content/citation.js +14 -5
- package/dist/content/learning.d.ts +1 -3
- package/dist/content/learning.js +14 -60
- package/dist/data/access.d.ts +1 -7
- package/dist/data/access.js +3 -10
- package/dist/finding/journal.js +0 -1
- package/dist/tools/extract.js +1 -1
- package/dist/tools/finding.js +1 -6
- package/dist/tools/search.js +2 -11
- package/dist/tools/session.js +0 -14
- package/package.json +1 -1
package/dist/capabilities/cli.js
CHANGED
package/dist/capabilities/mcp.js
CHANGED
|
@@ -40,6 +40,10 @@ export declare function inferCitationLocation(repoPath: string, commit: string):
|
|
|
40
40
|
};
|
|
41
41
|
export declare function buildCitationComment(citation: FindingCitation): string;
|
|
42
42
|
export declare function buildSourceComment(source: FindingProvenance): string;
|
|
43
|
+
/** Build a standalone scope comment. Returns empty string if scope is unset or "shared". */
|
|
44
|
+
export declare function buildScopeComment(scope: string | undefined): string;
|
|
45
|
+
/** Parse a standalone `<!-- scope:VALUE -->` comment. */
|
|
46
|
+
export declare function parseScopeComment(line: string): string | undefined;
|
|
43
47
|
export declare function parseSourceComment(line: string): FindingProvenance | null;
|
|
44
48
|
export declare function parseCitationComment(line: string): FindingCitation | null;
|
|
45
49
|
export declare function validateFindingCitation(citation: FindingCitation): boolean;
|
package/dist/content/citation.js
CHANGED
|
@@ -90,6 +90,20 @@ export function buildSourceComment(source) {
|
|
|
90
90
|
parts.push(`scope:${source.scope}`);
|
|
91
91
|
return parts.length > 0 ? `<!-- source:${parts.join(" ")} -->` : "";
|
|
92
92
|
}
|
|
93
|
+
/** Build a standalone scope comment. Returns empty string if scope is unset or "shared". */
|
|
94
|
+
export function buildScopeComment(scope) {
|
|
95
|
+
if (!scope || scope === "shared")
|
|
96
|
+
return "";
|
|
97
|
+
return `<!-- scope:${scope} -->`;
|
|
98
|
+
}
|
|
99
|
+
/** Parse a standalone `<!-- scope:VALUE -->` comment. */
|
|
100
|
+
export function parseScopeComment(line) {
|
|
101
|
+
const m = line.match(/<!--\s*scope:(".*?"|\S+)\s*-->/);
|
|
102
|
+
if (!m)
|
|
103
|
+
return undefined;
|
|
104
|
+
const raw = m[1].replace(/^"|"$/g, "").trim();
|
|
105
|
+
return raw || undefined;
|
|
106
|
+
}
|
|
93
107
|
export function parseSourceComment(line) {
|
|
94
108
|
const sourceMatch = line.match(METADATA_REGEX.source);
|
|
95
109
|
if (!sourceMatch)
|
|
@@ -416,11 +430,6 @@ export function filterTrustedFindingsDetailed(content, opts) {
|
|
|
416
430
|
}
|
|
417
431
|
if (!citation)
|
|
418
432
|
confidence *= 0.8;
|
|
419
|
-
const provenance = parseSourceComment(line)?.source ?? "unknown";
|
|
420
|
-
if (provenance === "human")
|
|
421
|
-
confidence *= 1.1;
|
|
422
|
-
if (provenance === "extract")
|
|
423
|
-
confidence *= 0.9;
|
|
424
433
|
if (project && highImpactFindingIds?.size) {
|
|
425
434
|
const findingId = findingIdFromLine(line);
|
|
426
435
|
if (highImpactFindingIds.has(findingId))
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type PhrenResult } from "../shared.js";
|
|
2
|
-
import { type FindingCitation
|
|
2
|
+
import { type FindingCitation } from "./citation.js";
|
|
3
3
|
interface AddFindingOptions {
|
|
4
4
|
extraAnnotations?: string[];
|
|
5
5
|
sessionId?: string;
|
|
6
|
-
source?: FindingProvenanceSource;
|
|
7
6
|
scope?: string;
|
|
8
7
|
}
|
|
9
8
|
export interface AddFindingResult {
|
|
@@ -16,7 +15,6 @@ export declare function addFindingToFile(phrenPath: string, project: string, lea
|
|
|
16
15
|
export declare function addFindingsToFile(phrenPath: string, project: string, learnings: string[], opts?: {
|
|
17
16
|
extraAnnotationsByFinding?: string[][];
|
|
18
17
|
sessionId?: string;
|
|
19
|
-
source?: FindingProvenanceSource;
|
|
20
18
|
scope?: string;
|
|
21
19
|
}): PhrenResult<{
|
|
22
20
|
added: string[];
|
package/dist/content/learning.js
CHANGED
|
@@ -5,12 +5,11 @@ import { debugLog, appendAuditLog, phrenOk, phrenErr, PhrenError } from "../shar
|
|
|
5
5
|
import { normalizeMemoryScope } from "../shared.js";
|
|
6
6
|
import { withFileLock } from "../shared/governance.js";
|
|
7
7
|
import { isValidProjectName, safeProjectPath } from "../utils.js";
|
|
8
|
-
import {
|
|
9
|
-
import { buildCitationComment, buildSourceComment, getHeadCommit, getRepoRoot, inferCitationLocation, isFindingProvenanceSource, } from "./citation.js";
|
|
8
|
+
import { buildCitationComment, buildScopeComment, getHeadCommit, getRepoRoot, inferCitationLocation, } from "./citation.js";
|
|
10
9
|
import { isDuplicateFinding, scanForSecrets, normalizeObservationTags, resolveCoref, detectConflicts, extractDynamicEntities } from "./dedup.js";
|
|
11
10
|
import { validateFindingsFormat, validateFinding } from "./validate.js";
|
|
12
11
|
import { countActiveFindings, autoArchiveToReference } from "./archive.js";
|
|
13
|
-
import { resolveAutoFindingTaskItem, resolveFindingTaskReference,
|
|
12
|
+
import { resolveAutoFindingTaskItem, resolveFindingTaskReference, } from "../finding/context.js";
|
|
14
13
|
import { buildLifecycleComments, extractFindingType, parseFindingLifecycle, stripLifecycleComments, } from "../finding/lifecycle.js";
|
|
15
14
|
import { METADATA_REGEX, } from "./metadata.js";
|
|
16
15
|
import { FINDINGS_FILENAME } from "../data/access.js";
|
|
@@ -43,51 +42,8 @@ function resolveInferredCitationRepo(citationInput) {
|
|
|
43
42
|
}
|
|
44
43
|
return undefined;
|
|
45
44
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
(process.env.PHREN_MODEL),
|
|
49
|
-
process.env.OPENAI_MODEL,
|
|
50
|
-
process.env.CLAUDE_MODEL,
|
|
51
|
-
(process.env.PHREN_LLM_MODEL),
|
|
52
|
-
process.env.MODEL,
|
|
53
|
-
];
|
|
54
|
-
return candidates.find((value) => typeof value === "string" && value.trim())?.trim();
|
|
55
|
-
}
|
|
56
|
-
function detectFindingTool() {
|
|
57
|
-
const candidates = [
|
|
58
|
-
(process.env.PHREN_TOOL),
|
|
59
|
-
(process.env.PHREN_HOOK_TOOL),
|
|
60
|
-
];
|
|
61
|
-
return candidates.find((value) => typeof value === "string" && value.trim())?.trim();
|
|
62
|
-
}
|
|
63
|
-
function detectFindingProvenanceSource(explicitSource) {
|
|
64
|
-
if (explicitSource)
|
|
65
|
-
return explicitSource;
|
|
66
|
-
const envSource = (process.env.PHREN_FINDING_SOURCE)?.trim().toLowerCase();
|
|
67
|
-
if (isFindingProvenanceSource(envSource))
|
|
68
|
-
return envSource;
|
|
69
|
-
if ((process.env.PHREN_CONSOLIDATION) === "1")
|
|
70
|
-
return "consolidation";
|
|
71
|
-
if ((process.env.PHREN_AUTO_EXTRACT) === "1")
|
|
72
|
-
return "extract";
|
|
73
|
-
if ((process.env.PHREN_HOOK_TOOL))
|
|
74
|
-
return "hook";
|
|
75
|
-
if (process.env.PHREN_ACTOR?.trim())
|
|
76
|
-
return "agent";
|
|
77
|
-
return "human";
|
|
78
|
-
}
|
|
79
|
-
function buildFindingSource(sessionId, explicitSource, scope) {
|
|
80
|
-
const actor = process.env.PHREN_ACTOR?.trim() || undefined;
|
|
81
|
-
const source = {
|
|
82
|
-
source: detectFindingProvenanceSource(explicitSource),
|
|
83
|
-
machine: getMachineName(),
|
|
84
|
-
actor,
|
|
85
|
-
tool: detectFindingTool(),
|
|
86
|
-
model: detectFindingModel(),
|
|
87
|
-
session_id: sessionId,
|
|
88
|
-
scope: normalizeMemoryScope(scope),
|
|
89
|
-
};
|
|
90
|
-
return source;
|
|
45
|
+
function buildFindingScope(scope) {
|
|
46
|
+
return normalizeMemoryScope(scope) || undefined;
|
|
91
47
|
}
|
|
92
48
|
function resolveFindingCitationInput(phrenPath, project, citationInput) {
|
|
93
49
|
const resolved = citationInput ? { ...citationInput } : {};
|
|
@@ -125,7 +81,7 @@ export function autoDetectFindingType(text) {
|
|
|
125
81
|
return null;
|
|
126
82
|
}
|
|
127
83
|
function prepareFinding(opts) {
|
|
128
|
-
const { finding: learning, project, fullHistory, extraAnnotations, citationInput,
|
|
84
|
+
const { finding: learning, project, fullHistory, extraAnnotations, citationInput, scope, nowIso, inferredRepo, headCommit, phrenPath } = opts;
|
|
129
85
|
const secretType = scanForSecrets(learning);
|
|
130
86
|
if (secretType) {
|
|
131
87
|
return { status: "rejected", reason: `Contains ${secretType}` };
|
|
@@ -146,11 +102,11 @@ function prepareFinding(opts) {
|
|
|
146
102
|
const fid = crypto.randomBytes(4).toString("hex");
|
|
147
103
|
const fidComment = `<!-- fid:${fid} -->`;
|
|
148
104
|
const createdComment = `<!-- created: ${today} -->`;
|
|
149
|
-
const
|
|
105
|
+
const scopeComment = buildScopeComment(scope);
|
|
150
106
|
let lifecycle = { status: "active", status_updated: today };
|
|
151
107
|
let bullet = `${normalizedLearning.startsWith("- ") ? normalizedLearning : `- ${normalizedLearning}`} ${fidComment} ${createdComment}`;
|
|
152
|
-
if (
|
|
153
|
-
bullet += ` ${
|
|
108
|
+
if (scopeComment)
|
|
109
|
+
bullet += ` ${scopeComment}`;
|
|
154
110
|
if (isDuplicateFinding(fullHistory, bullet)) {
|
|
155
111
|
return { status: "duplicate" };
|
|
156
112
|
}
|
|
@@ -274,8 +230,7 @@ export function addFindingToFile(phrenPath, project, learning, citationInput, op
|
|
|
274
230
|
if (!resolvedCitationInputResult.ok)
|
|
275
231
|
return resolvedCitationInputResult;
|
|
276
232
|
const resolvedCitationInput = resolvedCitationInputResult.data;
|
|
277
|
-
const
|
|
278
|
-
const source = buildFindingSource(effectiveSessionId, opts?.source, opts?.scope);
|
|
233
|
+
const scope = buildFindingScope(opts?.scope);
|
|
279
234
|
const inferredRepo = resolveInferredCitationRepo(resolvedCitationInput);
|
|
280
235
|
const headCommit = inferredRepo ? getHeadCommit(inferredRepo) : undefined;
|
|
281
236
|
const supersedesText = resolvedCitationInput?.supersedes;
|
|
@@ -296,7 +251,7 @@ export function addFindingToFile(phrenPath, project, learning, citationInput, op
|
|
|
296
251
|
const result = withFileLock(learningsPath, () => {
|
|
297
252
|
const preparedForNewFile = prepareFinding({
|
|
298
253
|
finding: learning, project, fullHistory: "", extraAnnotations: opts?.extraAnnotations,
|
|
299
|
-
citationInput: resolvedCitationInput,
|
|
254
|
+
citationInput: resolvedCitationInput, scope, nowIso, inferredRepo, headCommit, phrenPath,
|
|
300
255
|
});
|
|
301
256
|
if (!fs.existsSync(learningsPath)) {
|
|
302
257
|
if (preparedForNewFile.status === "rejected") {
|
|
@@ -329,7 +284,7 @@ export function addFindingToFile(phrenPath, project, learning, citationInput, op
|
|
|
329
284
|
: content;
|
|
330
285
|
const prepared = prepareFinding({
|
|
331
286
|
finding: learning, project, fullHistory: historyForDedup, extraAnnotations: opts?.extraAnnotations,
|
|
332
|
-
citationInput: resolvedCitationInput,
|
|
287
|
+
citationInput: resolvedCitationInput, scope, nowIso, inferredRepo, headCommit, phrenPath,
|
|
333
288
|
});
|
|
334
289
|
if (prepared.status === "rejected") {
|
|
335
290
|
return phrenErr(`Rejected: finding appears to contain a secret (${prepared.reason.replace(/^Contains /, "")}). Strip credentials before saving.`, PhrenError.VALIDATION_ERROR);
|
|
@@ -424,8 +379,7 @@ export function addFindingsToFile(phrenPath, project, learnings, opts) {
|
|
|
424
379
|
if (!resolvedCitationInputResult.ok)
|
|
425
380
|
return resolvedCitationInputResult;
|
|
426
381
|
const resolvedCitationInput = resolvedCitationInputResult.data;
|
|
427
|
-
const
|
|
428
|
-
const source = buildFindingSource(effectiveSessionId, opts?.source, opts?.scope);
|
|
382
|
+
const scope = buildFindingScope(opts?.scope);
|
|
429
383
|
const inferredRepo = resolveInferredCitationRepo(resolvedCitationInput);
|
|
430
384
|
const headCommit = inferredRepo ? getHeadCommit(inferredRepo) : undefined;
|
|
431
385
|
const added = [];
|
|
@@ -446,7 +400,7 @@ export function addFindingsToFile(phrenPath, project, learnings, opts) {
|
|
|
446
400
|
}
|
|
447
401
|
const prepared = prepareFinding({
|
|
448
402
|
finding: learning, project, fullHistory: content, extraAnnotations,
|
|
449
|
-
citationInput: resolvedCitationInput,
|
|
403
|
+
citationInput: resolvedCitationInput, scope, nowIso, inferredRepo, headCommit, phrenPath,
|
|
450
404
|
});
|
|
451
405
|
if (prepared.status === "rejected") {
|
|
452
406
|
rejected.push({ text: learning, reason: prepared.reason });
|
|
@@ -481,7 +435,7 @@ export function addFindingsToFile(phrenPath, project, learnings, opts) {
|
|
|
481
435
|
}
|
|
482
436
|
const prepared = prepareFinding({
|
|
483
437
|
finding: learning, project, fullHistory: content, extraAnnotations,
|
|
484
|
-
citationInput: resolvedCitationInput,
|
|
438
|
+
citationInput: resolvedCitationInput, scope, nowIso, inferredRepo, headCommit, phrenPath,
|
|
485
439
|
});
|
|
486
440
|
if (prepared.status === "rejected") {
|
|
487
441
|
rejected.push({ text: learning, reason: prepared.reason });
|
package/dist/data/access.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PhrenResult } from "../shared.js";
|
|
2
2
|
import { type AddFindingResult } from "../shared/content.js";
|
|
3
|
-
import { type FindingCitation
|
|
3
|
+
import { type FindingCitation } from "../content/citation.js";
|
|
4
4
|
import { type FindingLifecycleStatus } from "../finding/lifecycle.js";
|
|
5
5
|
export type { TaskSection, TaskItem, TaskDoc } from "./tasks.js";
|
|
6
6
|
export { readTasks, readTasksAcrossProjects, resolveTaskItem, addTask, addTasks, completeTasks, completeTask, removeTask, removeTasks, updateTask, linkTaskIssue, pinTask, unpinTask, workNextTask, tidyDoneTasks, taskMarkdown, appendChildFinding, promoteTask, TASKS_FILENAME, TASK_FILE_ALIASES, canonicalTaskFilePath, resolveTaskFilePath, isTaskFileName, type AddTaskOptions, } from "./tasks.js";
|
|
@@ -18,12 +18,6 @@ export interface FindingItem {
|
|
|
18
18
|
citationData?: FindingCitation;
|
|
19
19
|
taskItem?: string;
|
|
20
20
|
confidence?: number;
|
|
21
|
-
source: FindingProvenanceSource;
|
|
22
|
-
machine?: string;
|
|
23
|
-
actor?: string;
|
|
24
|
-
tool?: string;
|
|
25
|
-
model?: string;
|
|
26
|
-
sessionId?: string;
|
|
27
21
|
scope?: string;
|
|
28
22
|
/** First 60 chars of the newer finding that supersedes this one. Set when this finding is stale. */
|
|
29
23
|
supersededBy?: string;
|
package/dist/data/access.js
CHANGED
|
@@ -8,7 +8,7 @@ import { phrenErr, PhrenError, phrenOk, forwardErr, getProjectDirs, isRecord, }
|
|
|
8
8
|
import { normalizeQueueEntryText, } from "../shared/governance.js";
|
|
9
9
|
import { addFindingToFile, } from "../shared/content.js";
|
|
10
10
|
import { isValidProjectName, queueFilePath, safeProjectPath } from "../utils.js";
|
|
11
|
-
import { parseCitationComment, parseSourceComment, } from "../content/citation.js";
|
|
11
|
+
import { parseCitationComment, parseScopeComment, parseSourceComment, } from "../content/citation.js";
|
|
12
12
|
import { parseFindingLifecycle, } from "../finding/lifecycle.js";
|
|
13
13
|
import { METADATA_REGEX, isCitationLine, isArchiveStart, isArchiveEnd, parseFindingId, parseAllContradictions, stripComments, normalizeFindingText, } from "../content/metadata.js";
|
|
14
14
|
import { withSafeLock, ensureProject } from "../shared/data-utils.js";
|
|
@@ -162,7 +162,6 @@ export function readFindings(phrenPath, project, opts = {}) {
|
|
|
162
162
|
id: `L${index}`,
|
|
163
163
|
date,
|
|
164
164
|
text: syntheticText,
|
|
165
|
-
source: "unknown",
|
|
166
165
|
status: "active",
|
|
167
166
|
archived: inArchiveBlock,
|
|
168
167
|
tier: inArchiveBlock ? "archived" : "current",
|
|
@@ -175,7 +174,7 @@ export function readFindings(phrenPath, project, opts = {}) {
|
|
|
175
174
|
const next = lines[i + 1] || "";
|
|
176
175
|
const citation = isCitationLine(next) ? next.trim() : undefined;
|
|
177
176
|
const citationData = citation ? parseCitationComment(citation) ?? undefined : undefined;
|
|
178
|
-
const
|
|
177
|
+
const scope = parseScopeComment(line) ?? parseSourceComment(line)?.scope;
|
|
179
178
|
const stableId = parseFindingId(line);
|
|
180
179
|
const rawText = line.replace(/^-\s+/, "").trim();
|
|
181
180
|
const textWithoutComments = stripComments(rawText);
|
|
@@ -195,16 +194,10 @@ export function readFindings(phrenPath, project, opts = {}) {
|
|
|
195
194
|
date,
|
|
196
195
|
text,
|
|
197
196
|
confidence,
|
|
198
|
-
source: source?.source ?? "unknown",
|
|
199
197
|
citation,
|
|
200
198
|
citationData,
|
|
201
199
|
taskItem: citationData?.task_item,
|
|
202
|
-
|
|
203
|
-
actor: source?.actor,
|
|
204
|
-
tool: source?.tool,
|
|
205
|
-
model: source?.model,
|
|
206
|
-
sessionId: source?.session_id,
|
|
207
|
-
scope: source?.scope,
|
|
200
|
+
scope,
|
|
208
201
|
supersededBy: supersededByMatch ? supersededByMatch[1] : undefined,
|
|
209
202
|
supersedes: supersedesMatch ? supersedesMatch[1] : undefined,
|
|
210
203
|
contradicts: contradictsMatches.length > 0 ? contradictsMatches : undefined,
|
package/dist/finding/journal.js
CHANGED
|
@@ -99,7 +99,6 @@ export function compactFindingJournals(phrenPath, project) {
|
|
|
99
99
|
...(entry.commit ? { commit: entry.commit } : {}),
|
|
100
100
|
...(entry.file ? { file: entry.file } : {}),
|
|
101
101
|
}, {
|
|
102
|
-
source: entry.source,
|
|
103
102
|
sessionId: entry.sessionId,
|
|
104
103
|
});
|
|
105
104
|
if (!write.ok) {
|
package/dist/tools/extract.js
CHANGED
|
@@ -116,7 +116,7 @@ export function register(server, ctx) {
|
|
|
116
116
|
return withWriteQueue(async () => {
|
|
117
117
|
// Use addFindingsToFile so extracted findings go through the full pipeline:
|
|
118
118
|
// secret scan, dedup check, validation, and index update.
|
|
119
|
-
const result = addFindingsToFile(targetPath, project, findings
|
|
119
|
+
const result = addFindingsToFile(targetPath, project, findings);
|
|
120
120
|
if (!result.ok) {
|
|
121
121
|
return mcpResponse({ ok: false, error: result.error });
|
|
122
122
|
}
|
package/dist/tools/finding.js
CHANGED
|
@@ -14,7 +14,6 @@ import { extractFragmentNames } from "../shared/fragment-graph.js";
|
|
|
14
14
|
import { extractFactFromFinding } from "./extract-facts.js";
|
|
15
15
|
import { appendChildFinding, editFinding as editFindingCore, readFindings, FINDINGS_FILENAME } from "../data/access.js";
|
|
16
16
|
import { getActiveTaskForSession } from "../task/lifecycle.js";
|
|
17
|
-
import { FINDING_PROVENANCE_SOURCES } from "../content/citation.js";
|
|
18
17
|
import { isInactiveFindingLine, supersedeFinding, retractFinding as retractFindingLifecycle, resolveFindingContradiction, } from "../finding/lifecycle.js";
|
|
19
18
|
import { permissionDeniedError } from "../governance/rbac.js";
|
|
20
19
|
const JACCARD_MAYBE_LOW = 0.25;
|
|
@@ -85,7 +84,7 @@ function withLifecycleMutation(phrenPath, project, writeQueue, updateIndex, hand
|
|
|
85
84
|
}
|
|
86
85
|
// ── Handlers ─────────────────────────────────────────────────────────────────
|
|
87
86
|
async function handleAddFinding(ctx, params) {
|
|
88
|
-
const { finding, citation, sessionId,
|
|
87
|
+
const { finding, citation, sessionId, findingType, scope } = params;
|
|
89
88
|
// Resolve store-qualified project names (e.g., "team/arc" → store path + "arc")
|
|
90
89
|
let phrenPath;
|
|
91
90
|
let project;
|
|
@@ -186,7 +185,6 @@ async function handleAddFinding(ctx, params) {
|
|
|
186
185
|
runCustomHooks(phrenPath, "pre-finding", { PHREN_PROJECT: project });
|
|
187
186
|
const result = addFindingToFile(phrenPath, project, taggedFinding, citation, {
|
|
188
187
|
sessionId,
|
|
189
|
-
source,
|
|
190
188
|
scope: normalizedScope,
|
|
191
189
|
extraAnnotations: semanticConflicts.checked ? semanticConflicts.annotations : undefined,
|
|
192
190
|
});
|
|
@@ -627,9 +625,6 @@ export function register(server, ctx) {
|
|
|
627
625
|
task_item: z.string().optional().describe("Task item stable ID like bid:abcd1234, positional ID like A1, or item text to link this finding to."),
|
|
628
626
|
}).optional().describe("Optional source citation for traceability (only used when finding is a single string)."),
|
|
629
627
|
sessionId: z.string().optional().describe("Optional session ID from session_start. Pass this if you want session metrics to include this write."),
|
|
630
|
-
source: z.enum(FINDING_PROVENANCE_SOURCES)
|
|
631
|
-
.optional()
|
|
632
|
-
.describe("Optional finding provenance source: human, agent, hook, extract, consolidation, or unknown."),
|
|
633
628
|
findingType: z.enum(FINDING_TYPES)
|
|
634
629
|
.optional()
|
|
635
630
|
.describe("Classify this finding: 'decision' (architectural choice with rationale), 'pitfall' (bug or failure mode to avoid), 'pattern' (reusable approach that works well), 'tradeoff' (deliberate compromise), 'architecture' (structural design note), 'bug' (confirmed defect or failure)."),
|
package/dist/tools/search.js
CHANGED
|
@@ -14,7 +14,7 @@ import { runCustomHooks } from "../hooks.js";
|
|
|
14
14
|
import { entryScoreKey, getQualityMultiplier, getRetentionPolicy } from "../shared/governance.js";
|
|
15
15
|
import { callLlm } from "../content/dedup.js";
|
|
16
16
|
import { rankResults, searchKnowledgeRows, applyTrustFilter, searchFederatedStores } from "../shared/retrieval.js";
|
|
17
|
-
import { parseSourceComment } from "../content/citation.js";
|
|
17
|
+
import { parseScopeComment, parseSourceComment } from "../content/citation.js";
|
|
18
18
|
import { resolveActiveSessionScope } from "./session.js";
|
|
19
19
|
import { logger } from "../logger.js";
|
|
20
20
|
/**
|
|
@@ -79,8 +79,7 @@ function filterFindingsContentByScope(content, activeScope) {
|
|
|
79
79
|
let keepCitation = false;
|
|
80
80
|
for (const line of lines) {
|
|
81
81
|
if (line.startsWith("- ")) {
|
|
82
|
-
const
|
|
83
|
-
const itemScope = normalizeMemoryScope(source?.scope);
|
|
82
|
+
const itemScope = normalizeMemoryScope(parseScopeComment(line) ?? parseSourceComment(line)?.scope);
|
|
84
83
|
keepCitation = isMemoryScopeVisible(itemScope, activeScope);
|
|
85
84
|
if (keepCitation)
|
|
86
85
|
out.push(line);
|
|
@@ -658,16 +657,8 @@ async function handleGetFindings(ctx, { project, limit, include_superseded, incl
|
|
|
658
657
|
metadata.push(`status=${entry.status}`);
|
|
659
658
|
if (entry.taskItem)
|
|
660
659
|
metadata.push(`task=${entry.taskItem}`);
|
|
661
|
-
if (entry.sessionId)
|
|
662
|
-
metadata.push(`session=${entry.sessionId.slice(0, 8)}`);
|
|
663
660
|
if (entry.scope)
|
|
664
661
|
metadata.push(`scope=${entry.scope}`);
|
|
665
|
-
if (entry.actor)
|
|
666
|
-
metadata.push(`actor=${entry.actor}`);
|
|
667
|
-
if (entry.tool)
|
|
668
|
-
metadata.push(`tool=${entry.tool}`);
|
|
669
|
-
if (entry.model)
|
|
670
|
-
metadata.push(`model=${entry.model}`);
|
|
671
662
|
if (entry.supersedes)
|
|
672
663
|
metadata.push(`supersedes="${entry.supersedes.slice(0, 30)}"`);
|
|
673
664
|
if (entry.supersededBy)
|
package/dist/tools/session.js
CHANGED
|
@@ -270,20 +270,6 @@ export async function getSessionArtifacts(phrenPath, sessionId, project) {
|
|
|
270
270
|
if (seen.has(proj))
|
|
271
271
|
return;
|
|
272
272
|
seen.add(proj);
|
|
273
|
-
// Findings with matching sessionId
|
|
274
|
-
const findingsResult = readFindings(storePath, proj);
|
|
275
|
-
if (findingsResult.ok) {
|
|
276
|
-
for (const f of findingsResult.data) {
|
|
277
|
-
if (f.sessionId && (f.sessionId === sessionId || f.sessionId.startsWith(shortId))) {
|
|
278
|
-
findings.push({
|
|
279
|
-
project: proj,
|
|
280
|
-
id: f.id,
|
|
281
|
-
date: f.date,
|
|
282
|
-
text: f.text,
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
273
|
// Tasks with matching sessionId
|
|
288
274
|
const tasksResult = readTasks(storePath, proj);
|
|
289
275
|
if (tasksResult.ok) {
|