@phren/cli 0.0.57 → 0.0.58
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.d.ts +2 -0
- package/dist/capabilities/index.d.ts +7 -0
- package/dist/capabilities/mcp.d.ts +2 -0
- package/dist/capabilities/types.d.ts +12 -0
- package/dist/capabilities/vscode.d.ts +2 -0
- package/dist/capabilities/web-ui.d.ts +2 -0
- package/dist/cli/actions.d.ts +16 -0
- package/dist/cli/cli.d.ts +3 -0
- package/dist/cli/config.d.ts +24 -0
- package/dist/cli/extract.d.ts +22 -0
- package/dist/cli/govern.d.ts +11 -0
- package/dist/cli/graph.d.ts +15 -0
- package/dist/cli/hooks-citations.d.ts +8 -0
- package/dist/cli/hooks-context.d.ts +34 -0
- package/dist/cli/hooks-globs.d.ts +2 -0
- package/dist/cli/hooks-output.d.ts +2 -0
- package/dist/cli/hooks-session.d.ts +38 -0
- package/dist/cli/hooks.d.ts +12 -0
- package/dist/cli/namespaces.d.ts +11 -0
- package/dist/cli/ops.d.ts +5 -0
- package/dist/cli/search.d.ts +38 -0
- package/dist/cli/team.d.ts +1 -0
- package/dist/cli-hooks-git.d.ts +35 -0
- package/dist/cli-hooks-prompt.d.ts +18 -0
- package/dist/cli-hooks-session-handlers.d.ts +3 -0
- package/dist/cli-hooks-stop.d.ts +11 -0
- package/dist/content/archive.d.ts +13 -0
- package/dist/content/citation.d.ts +50 -0
- package/dist/content/dedup.d.ts +55 -0
- package/dist/content/learning.d.ts +29 -0
- package/dist/content/metadata.d.ts +107 -0
- package/dist/content/validate.d.ts +70 -0
- package/dist/core/finding.d.ts +25 -0
- package/dist/core/project.d.ts +16 -0
- package/dist/core/search.d.ts +13 -0
- package/dist/data/access.d.ts +83 -0
- package/dist/data/tasks.d.ts +89 -0
- package/dist/embedding.d.ts +54 -0
- package/dist/entrypoint.d.ts +1 -0
- package/dist/finding/context.d.ts +8 -0
- package/dist/finding/impact.d.ts +11 -0
- package/dist/finding/journal.d.ts +40 -0
- package/dist/finding/lifecycle.d.ts +40 -0
- package/dist/governance/audit.d.ts +1 -0
- package/dist/governance/locks.d.ts +3 -0
- package/dist/governance/policy.d.ts +109 -0
- package/dist/governance/rbac.d.ts +25 -0
- package/dist/governance/scores.d.ts +12 -0
- package/dist/hooks.d.ts +59 -0
- package/dist/index-query.d.ts +33 -0
- package/dist/index.d.ts +2 -0
- package/dist/init/config.d.ts +43 -0
- package/dist/init/init-configure.d.ts +21 -0
- package/dist/init/init-hooks-mode.d.ts +1 -0
- package/dist/init/init-mcp-mode.d.ts +1 -0
- package/dist/init/init-uninstall.d.ts +3 -0
- package/dist/init/init-walkthrough.d.ts +61 -0
- package/dist/init/init.d.ts +84 -0
- package/dist/init/preferences.d.ts +28 -0
- package/dist/init/setup.d.ts +86 -0
- package/dist/init/shared.d.ts +13 -0
- package/dist/init-bootstrap.d.ts +5 -0
- package/dist/init-detect.d.ts +8 -0
- package/dist/init-env.d.ts +6 -0
- package/dist/init-fresh.d.ts +10 -0
- package/dist/init-hooks.d.ts +5 -0
- package/dist/init-mcp.d.ts +8 -0
- package/dist/init-modes.d.ts +4 -0
- package/dist/init-npm.d.ts +10 -0
- package/dist/init-project-local.d.ts +2 -0
- package/dist/init-semantic.d.ts +4 -0
- package/dist/init-types.d.ts +59 -0
- package/dist/init-uninstall.d.ts +3 -0
- package/dist/init-update.d.ts +10 -0
- package/dist/init-walkthrough.d.ts +55 -0
- package/dist/link/checksums.d.ts +8 -0
- package/dist/link/context.d.ts +7 -0
- package/dist/link/doctor.d.ts +2 -0
- package/dist/link/link.d.ts +29 -0
- package/dist/link/skills.d.ts +47 -0
- package/dist/logger.d.ts +9 -0
- package/dist/machine-identity.d.ts +4 -0
- package/dist/package-metadata.d.ts +4 -0
- package/dist/phren-art.d.ts +26 -0
- package/dist/phren-core.d.ts +64 -0
- package/dist/phren-dotenv.d.ts +2 -0
- package/dist/phren-paths.d.ts +60 -0
- package/dist/proactivity.d.ts +13 -0
- package/dist/profile-store.d.ts +34 -0
- package/dist/project-config.d.ts +60 -0
- package/dist/project-locator.d.ts +1 -0
- package/dist/project-topics.d.ts +122 -0
- package/dist/provider-adapters.d.ts +34 -0
- package/dist/query-correlation.d.ts +31 -0
- package/dist/runtime-profile.d.ts +6 -0
- package/dist/session/checkpoints.d.ts +25 -0
- package/dist/session/utils.d.ts +43 -0
- package/dist/shared/content.d.ts +7 -0
- package/dist/shared/data-utils.d.ts +8 -0
- package/dist/shared/embedding-cache.d.ts +30 -0
- package/dist/shared/fragment-graph.d.ts +60 -0
- package/dist/shared/governance.d.ts +4 -0
- package/dist/shared/index.d.ts +29 -0
- package/dist/shared/ollama.d.ts +28 -0
- package/dist/shared/process.d.ts +17 -0
- package/dist/shared/retrieval.d.ts +84 -0
- package/dist/shared/search-fallback.d.ts +23 -0
- package/dist/shared/sqljs.d.ts +5 -0
- package/dist/shared/stemmer.d.ts +5 -0
- package/dist/shared/vector-index.d.ts +18 -0
- package/dist/shared.d.ts +9 -0
- package/dist/shell/entry.d.ts +26 -0
- package/dist/shell/input.d.ts +57 -0
- package/dist/shell/palette.d.ts +13 -0
- package/dist/shell/render-api.d.ts +29 -0
- package/dist/shell/render.d.ts +50 -0
- package/dist/shell/shell.d.ts +61 -0
- package/dist/shell/state-store.d.ts +14 -0
- package/dist/shell/types.d.ts +29 -0
- package/dist/shell/view-list.d.ts +5 -0
- package/dist/shell/view.d.ts +34 -0
- package/dist/skill/files.d.ts +5 -0
- package/dist/skill/registry.d.ts +55 -0
- package/dist/skill/state.d.ts +3 -0
- package/dist/startup-embedding.d.ts +15 -0
- package/dist/status.d.ts +1 -0
- package/dist/store-registry.d.ts +60 -0
- package/dist/store-routing.d.ts +37 -0
- package/dist/task/github.d.ts +22 -0
- package/dist/task/hygiene.d.ts +13 -0
- package/dist/task/lifecycle.d.ts +26 -0
- package/dist/telemetry.d.ts +10 -0
- package/dist/test-global-setup.d.ts +14 -0
- package/dist/tool-registry.d.ts +14 -0
- package/dist/tools/config.d.ts +3 -0
- package/dist/tools/data.d.ts +3 -0
- package/dist/tools/extract-facts.d.ts +17 -0
- package/dist/tools/extract.d.ts +3 -0
- package/dist/tools/finding.d.ts +3 -0
- package/dist/tools/graph.d.ts +3 -0
- package/dist/tools/hooks.d.ts +3 -0
- package/dist/tools/memory.d.ts +3 -0
- package/dist/tools/ops.d.ts +3 -0
- package/dist/tools/search.d.ts +8 -0
- package/dist/tools/session.d.ts +44 -0
- package/dist/tools/skills.d.ts +3 -0
- package/dist/tools/tasks.d.ts +3 -0
- package/dist/tools/types.d.ts +50 -0
- package/dist/ui/assets.d.ts +2 -0
- package/dist/ui/data.d.ts +113 -0
- package/dist/ui/graph.d.ts +1 -0
- package/dist/ui/memory-ui.d.ts +4 -0
- package/dist/ui/page.d.ts +2 -0
- package/dist/ui/scripts.d.ts +17 -0
- package/dist/ui/server.d.ts +17 -0
- package/dist/ui/styles.d.ts +4 -0
- package/dist/update.d.ts +9 -0
- package/dist/utils-fts.d.ts +12 -0
- package/dist/utils-fts.js +450 -0
- package/dist/utils-helpers.d.ts +12 -0
- package/dist/utils-helpers.js +80 -0
- package/dist/utils-paths.d.ts +3 -0
- package/dist/utils-paths.js +61 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +8 -587
- package/package.json +45 -11
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consolidated metadata regex patterns and parsing helpers for HTML comment
|
|
3
|
+
* metadata embedded in FINDINGS.md and related files.
|
|
4
|
+
*
|
|
5
|
+
* `phren:` prefixes are used for HTML comment metadata.
|
|
6
|
+
*/
|
|
7
|
+
export declare const METADATA_REGEX: {
|
|
8
|
+
/** Matches `<!-- phren:status "active" -->` or `<!-- phren:status "superseded" -->` etc. */
|
|
9
|
+
readonly status: RegExp;
|
|
10
|
+
/** Matches `<!-- phren:status_updated "2025-01-01" -->` */
|
|
11
|
+
readonly statusUpdated: RegExp;
|
|
12
|
+
/** Matches `<!-- phren:status_reason "superseded_by" -->` */
|
|
13
|
+
readonly statusReason: RegExp;
|
|
14
|
+
/** Matches `<!-- phren:status_ref "some ref" -->` */
|
|
15
|
+
readonly statusRef: RegExp;
|
|
16
|
+
/** Generic field matcher factory for status_updated / status_reason / status_ref. */
|
|
17
|
+
readonly statusField: (field: string) => RegExp;
|
|
18
|
+
/** Raw (unquoted) fallback for status fields: `<!-- phren:status_ref some text -->` */
|
|
19
|
+
readonly statusFieldRaw: (field: string) => RegExp;
|
|
20
|
+
/** Matches `<!-- phren:superseded_by "text" 2025-01-01 -->` */
|
|
21
|
+
readonly supersededBy: RegExp;
|
|
22
|
+
/** Legacy `<!-- superseded_by: "text" -->` */
|
|
23
|
+
readonly supersededByLegacy: RegExp;
|
|
24
|
+
/** Matches `<!-- phren:supersedes "text" -->` */
|
|
25
|
+
readonly supersedes: RegExp;
|
|
26
|
+
/** Matches `<!-- phren:contradicts "text" -->` */
|
|
27
|
+
readonly contradicts: RegExp;
|
|
28
|
+
/** Global version for matchAll */
|
|
29
|
+
readonly contradictsAll: RegExp;
|
|
30
|
+
/** Legacy `<!-- conflicts_with: "text" -->` or `<!-- conflicts_with: "text" (from project: foo) -->` */
|
|
31
|
+
readonly conflictsWith: RegExp;
|
|
32
|
+
/** Global version for matchAll on conflicts_with */
|
|
33
|
+
readonly conflictsWithAll: RegExp;
|
|
34
|
+
/** Matches `<!-- phren:cite {...} -->` or `<!-- phren:cite {...} -->` on a full line. */
|
|
35
|
+
readonly citation: RegExp;
|
|
36
|
+
/** Matches the opening marker (not line-anchored) for extracting JSON payload. */
|
|
37
|
+
readonly citationMarker: RegExp;
|
|
38
|
+
/** Matches `<!-- phren:archive:start -->` or `<!-- phren:archive:start -->` */
|
|
39
|
+
readonly archiveStart: RegExp;
|
|
40
|
+
/** Matches `<!-- phren:archive:end -->` or `<!-- phren:archive:end -->` */
|
|
41
|
+
readonly archiveEnd: RegExp;
|
|
42
|
+
/** Matches `<!-- fid:abcd1234 -->` */
|
|
43
|
+
readonly findingId: RegExp;
|
|
44
|
+
/** Matches `<!-- created: 2025-01-01 -->` */
|
|
45
|
+
readonly createdDate: RegExp;
|
|
46
|
+
/** Matches any lifecycle annotation: status, status_updated, status_reason, status_ref */
|
|
47
|
+
readonly lifecycleAnnotation: RegExp;
|
|
48
|
+
/** Matches `<!-- source:... -->` */
|
|
49
|
+
readonly source: RegExp;
|
|
50
|
+
/** Matches any HTML comment `<!-- ... -->` (non-greedy). */
|
|
51
|
+
readonly anyComment: RegExp;
|
|
52
|
+
/** Strip status comment */
|
|
53
|
+
readonly stripStatus: RegExp;
|
|
54
|
+
/** Strip status_updated comment */
|
|
55
|
+
readonly stripStatusUpdated: RegExp;
|
|
56
|
+
/** Strip status_reason comment */
|
|
57
|
+
readonly stripStatusReason: RegExp;
|
|
58
|
+
/** Strip status_ref comment */
|
|
59
|
+
readonly stripStatusRef: RegExp;
|
|
60
|
+
/** Strip legacy `<!-- superseded_by: "..." -->` */
|
|
61
|
+
readonly stripSupersededByLegacy: RegExp;
|
|
62
|
+
/** Strip `<!-- phren:superseded_by "..." ... -->` */
|
|
63
|
+
readonly stripSupersededBy: RegExp;
|
|
64
|
+
/** Strip `<!-- phren:supersedes "..." -->` */
|
|
65
|
+
readonly stripSupersedes: RegExp;
|
|
66
|
+
/** Strip legacy `<!-- conflicts_with: "..." -->` */
|
|
67
|
+
readonly stripConflictsWith: RegExp;
|
|
68
|
+
/** Strip `<!-- phren:contradicts "..." -->` */
|
|
69
|
+
readonly stripContradicts: RegExp;
|
|
70
|
+
};
|
|
71
|
+
/** Parse `<!-- phren:status "active" -->` from a line. Returns the status string or undefined. */
|
|
72
|
+
export declare function parseStatus(line: string): string | undefined;
|
|
73
|
+
/** Parse a quoted status field (status_updated, status_reason, status_ref) from a line. */
|
|
74
|
+
export declare function parseStatusField(line: string, field: string): string | undefined;
|
|
75
|
+
/** Parse supersession metadata: returns `{ ref, date }` or null. Checks both prefixed and legacy forms. */
|
|
76
|
+
export declare function parseSupersession(line: string): {
|
|
77
|
+
ref: string;
|
|
78
|
+
date?: string;
|
|
79
|
+
} | null;
|
|
80
|
+
/** Parse `<!-- phren:supersedes "..." -->` from a line. Returns the ref or undefined. */
|
|
81
|
+
export declare function parseSupersedesRef(line: string): string | undefined;
|
|
82
|
+
/** Parse contradiction metadata. Checks both prefixed `contradicts` and legacy `conflicts_with`. */
|
|
83
|
+
export declare function parseContradiction(line: string): string | null;
|
|
84
|
+
/** Parse all contradiction refs from a line using matchAll. */
|
|
85
|
+
export declare function parseAllContradictions(line: string): string[];
|
|
86
|
+
/** Parse `<!-- fid:XXXXXXXX -->` from a line. Returns the 8-char hex ID or undefined. */
|
|
87
|
+
export declare function parseFindingId(line: string): string | undefined;
|
|
88
|
+
/** Parse `<!-- created: YYYY-MM-DD -->` from a line. Returns the date string or undefined. */
|
|
89
|
+
export declare function parseCreatedDate(line: string): string | undefined;
|
|
90
|
+
/** Check if a line (or next line) contains a citation comment. */
|
|
91
|
+
export declare function isCitationLine(line: string): boolean;
|
|
92
|
+
/** Check if a line marks the start of an archive block. */
|
|
93
|
+
export declare function isArchiveStart(line: string): boolean;
|
|
94
|
+
/** Check if a line marks the end of an archive block. */
|
|
95
|
+
export declare function isArchiveEnd(line: string): boolean;
|
|
96
|
+
/** Strip all lifecycle status comments (status, status_updated, status_reason, status_ref). */
|
|
97
|
+
export declare function stripLifecycleMetadata(line: string): string;
|
|
98
|
+
/** Strip all relation comments (superseded_by, supersedes, conflicts_with, contradicts). */
|
|
99
|
+
export declare function stripRelationMetadata(line: string): string;
|
|
100
|
+
/** Strip all phren/phren metadata comments from a line. */
|
|
101
|
+
export declare function stripAllMetadata(line: string): string;
|
|
102
|
+
/** Strip all HTML comments from text. */
|
|
103
|
+
export declare function stripComments(text: string): string;
|
|
104
|
+
/** Normalize finding text for comparison: strips bullet prefix, HTML comments, confidence tags, normalizes whitespace, lowercases. */
|
|
105
|
+
export declare function normalizeFindingText(raw: string): string;
|
|
106
|
+
/** Build a metadata comment string. */
|
|
107
|
+
export declare function addMetadata(type: string, value: string, extra?: string): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Maximum allowed length for a single finding entry (token budget protection). */
|
|
2
|
+
export declare const MAX_FINDING_LENGTH = 2000;
|
|
3
|
+
export interface ConsolidationNeeded {
|
|
4
|
+
project: string;
|
|
5
|
+
entriesSince: number;
|
|
6
|
+
daysSince: number | null;
|
|
7
|
+
lastConsolidated: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface ConsolidationStatus extends ConsolidationNeeded {
|
|
10
|
+
recommended: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Thresholds used for consolidation recommendations. */
|
|
13
|
+
export declare const CONSOLIDATION_ENTRY_THRESHOLD = 25;
|
|
14
|
+
/**
|
|
15
|
+
* Validate a single finding text before it is persisted.
|
|
16
|
+
* Returns null if valid, or an error message string if invalid.
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateFinding(text: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Compute consolidation status for a single project directory.
|
|
21
|
+
* Returns null if the project has no FINDINGS.md.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getProjectConsolidationStatus(dir: string): ConsolidationStatus | null;
|
|
24
|
+
/**
|
|
25
|
+
* Check which projects have enough new findings to warrant consolidation.
|
|
26
|
+
* Returns projects that exceed the entry or time thresholds.
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkConsolidationNeeded(phrenPath: string, profile?: string): ConsolidationNeeded[];
|
|
29
|
+
/**
|
|
30
|
+
* Validate FINDINGS.md format and structure.
|
|
31
|
+
* Returns an array of issue description strings (empty array means valid).
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateFindingsFormat(content: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Strip the ## Done section (and equivalents) from task content to reduce index bloat.
|
|
36
|
+
* Keeps the title, Active, and Queue sections which are the actionable parts.
|
|
37
|
+
* Handles: Done, Completed, Archived, Finished, Complete.
|
|
38
|
+
*/
|
|
39
|
+
export declare function stripTaskDoneSection(content: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Validate tasks.md format and structure.
|
|
42
|
+
* Returns an array of issue description strings (empty array means valid).
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateTaskFormat(content: string): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Extract ours/theirs versions from a file containing git conflict markers.
|
|
47
|
+
* Returns null if no conflict markers are found.
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractConflictVersions(content: string): {
|
|
50
|
+
ours: string;
|
|
51
|
+
theirs: string;
|
|
52
|
+
} | null;
|
|
53
|
+
/**
|
|
54
|
+
* Merge two FINDINGS.md versions: union entries per date, newest date first.
|
|
55
|
+
* Deduplicates by bullet text only, keeping comment lines from whichever
|
|
56
|
+
* version is kept (ours takes priority).
|
|
57
|
+
* Preserves preamble content (consolidated markers) and postamble (archive blocks).
|
|
58
|
+
*/
|
|
59
|
+
export declare function mergeFindings(ours: string, theirs: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Merge two tasks.md versions: union items per section, deduplicated by stable ID when
|
|
62
|
+
* present or by normalised bullet text otherwise. Context/continuation lines are preserved.
|
|
63
|
+
* Ours wins on conflict. Section order follows Active > Queue > Done.
|
|
64
|
+
*/
|
|
65
|
+
export declare function mergeTask(ours: string, theirs: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Attempt to auto-resolve git conflicts in FINDINGS.md and tasks.md files.
|
|
68
|
+
* Returns true if all conflicts were resolved, false if any remain.
|
|
69
|
+
*/
|
|
70
|
+
export declare function autoMergeConflicts(phrenPath: string): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface FindingResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
message: string;
|
|
4
|
+
data?: unknown;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Validate and add a single finding. Shared validation logic used by
|
|
8
|
+
* both CLI `phren add-finding` and MCP `add_finding` tool.
|
|
9
|
+
*/
|
|
10
|
+
export declare function addFinding(phrenPath: string, project: string, finding: string, citation?: {
|
|
11
|
+
file?: string;
|
|
12
|
+
line?: number;
|
|
13
|
+
repo?: string;
|
|
14
|
+
commit?: string;
|
|
15
|
+
supersedes?: string;
|
|
16
|
+
}, findingType?: string): FindingResult;
|
|
17
|
+
/**
|
|
18
|
+
* Remove a finding by partial text match.
|
|
19
|
+
*/
|
|
20
|
+
export declare function removeFinding(phrenPath: string, project: string, finding: string): FindingResult;
|
|
21
|
+
/**
|
|
22
|
+
* Remove multiple findings by partial text match.
|
|
23
|
+
*/
|
|
24
|
+
export declare function removeFindings(phrenPath: string, project: string, findings: string[]): FindingResult;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PhrenResult } from "../shared.js";
|
|
2
|
+
import type { ProjectOwnershipMode } from "../project-config.js";
|
|
3
|
+
interface AddedProjectData {
|
|
4
|
+
project: string;
|
|
5
|
+
path: string;
|
|
6
|
+
profile: string | null;
|
|
7
|
+
ownership: ProjectOwnershipMode;
|
|
8
|
+
files: {
|
|
9
|
+
claude: string | null;
|
|
10
|
+
summary: string;
|
|
11
|
+
findings: string;
|
|
12
|
+
task: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare function addProjectFromPath(phrenPath: string, targetPath: string | undefined, requestedProfile?: string, ownership?: ProjectOwnershipMode): PhrenResult<AddedProjectData>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DocRow, SqlJsDatabase } from "../shared/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Keyword overlap fallback for when FTS5 returns no results.
|
|
4
|
+
* Scans all docs (optionally filtered by project/type), scores each by
|
|
5
|
+
* how many query terms appear in its content, and returns top matches.
|
|
6
|
+
*
|
|
7
|
+
* Shared between the MCP search tool and CLI `phren search`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function keywordFallbackSearch(db: SqlJsDatabase, query: string, opts: {
|
|
10
|
+
project?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
limit: number;
|
|
13
|
+
}): DocRow[] | null;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type PhrenResult } from "../shared.js";
|
|
2
|
+
import { type AddFindingResult } from "../shared/content.js";
|
|
3
|
+
import { type FindingCitation, type FindingProvenanceSource } from "../content/citation.js";
|
|
4
|
+
import { type FindingLifecycleStatus } from "../finding/lifecycle.js";
|
|
5
|
+
export type { TaskSection, TaskItem, TaskDoc } from "./tasks.js";
|
|
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";
|
|
7
|
+
export { addProjectToProfile, listMachines, listProfiles, listProjectCards, removeProjectFromProfile, setMachineProfile, type ProfileInfo, type ProjectCard, } from "../profile-store.js";
|
|
8
|
+
export { loadShellState, resetShellState, saveShellState, type ShellState, } from "../shell/state-store.js";
|
|
9
|
+
export { getRuntimeHealth as readRuntimeHealth } from "../shared/governance.js";
|
|
10
|
+
export interface FindingItem {
|
|
11
|
+
id: string;
|
|
12
|
+
/** Stable 8-char hex ID embedded as `<!-- fid:XXXXXXXX -->`. Survives reordering and consolidation. */
|
|
13
|
+
stableId?: string;
|
|
14
|
+
date: string;
|
|
15
|
+
text: string;
|
|
16
|
+
citation?: string;
|
|
17
|
+
citationData?: FindingCitation;
|
|
18
|
+
taskItem?: string;
|
|
19
|
+
confidence?: number;
|
|
20
|
+
source: FindingProvenanceSource;
|
|
21
|
+
machine?: string;
|
|
22
|
+
actor?: string;
|
|
23
|
+
tool?: string;
|
|
24
|
+
model?: string;
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
scope?: string;
|
|
27
|
+
/** First 60 chars of the newer finding that supersedes this one. Set when this finding is stale. */
|
|
28
|
+
supersededBy?: string;
|
|
29
|
+
/** First 60 chars of the older finding this one replaces. */
|
|
30
|
+
supersedes?: string;
|
|
31
|
+
/** Snippets of findings this one contradicts. */
|
|
32
|
+
contradicts?: string[];
|
|
33
|
+
status: FindingLifecycleStatus;
|
|
34
|
+
status_updated?: string;
|
|
35
|
+
status_reason?: string;
|
|
36
|
+
status_ref?: string;
|
|
37
|
+
/** Indicates whether this item comes from archived history blocks (<details> / phren:archive). */
|
|
38
|
+
archived?: boolean;
|
|
39
|
+
/** Tier marker used to distinguish current truth vs archived history. */
|
|
40
|
+
tier?: "current" | "archived";
|
|
41
|
+
}
|
|
42
|
+
export interface ReadFindingsOptions {
|
|
43
|
+
includeArchived?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface FindingHistoryEntry {
|
|
46
|
+
id: string;
|
|
47
|
+
stableId?: string;
|
|
48
|
+
text: string;
|
|
49
|
+
timeline: FindingItem[];
|
|
50
|
+
current?: FindingItem;
|
|
51
|
+
archivedCount: number;
|
|
52
|
+
}
|
|
53
|
+
export interface QueueItem {
|
|
54
|
+
id: string;
|
|
55
|
+
section: "Review" | "Stale" | "Conflicts";
|
|
56
|
+
date: string;
|
|
57
|
+
text: string;
|
|
58
|
+
line: string;
|
|
59
|
+
confidence?: number;
|
|
60
|
+
risky: boolean;
|
|
61
|
+
machine?: string;
|
|
62
|
+
model?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ProjectQueueItem extends QueueItem {
|
|
65
|
+
project: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function readFindings(phrenPath: string, project: string, opts?: ReadFindingsOptions): PhrenResult<FindingItem[]>;
|
|
68
|
+
export declare function readFindingHistory(phrenPath: string, project: string, findingId?: string): PhrenResult<FindingHistoryEntry[]>;
|
|
69
|
+
export declare function addFinding(phrenPath: string, project: string, learning: string): PhrenResult<AddFindingResult>;
|
|
70
|
+
export declare function removeFinding(phrenPath: string, project: string, match: string): PhrenResult<string>;
|
|
71
|
+
export declare function removeFindings(phrenPath: string, project: string, matches: string[]): PhrenResult<{
|
|
72
|
+
removed: string[];
|
|
73
|
+
errors: string[];
|
|
74
|
+
}>;
|
|
75
|
+
export declare function editFinding(phrenPath: string, project: string, oldText: string, newText: string): PhrenResult<string>;
|
|
76
|
+
export declare function readReviewQueue(phrenPath: string, project: string): PhrenResult<QueueItem[]>;
|
|
77
|
+
/** Remove a queue item's line from review.md (finding stays in FINDINGS.md). */
|
|
78
|
+
export declare function approveQueueItem(phrenPath: string, project: string, lineText: string): PhrenResult<string>;
|
|
79
|
+
/** Remove a queue item from review.md AND remove the corresponding finding from FINDINGS.md. */
|
|
80
|
+
export declare function rejectQueueItem(phrenPath: string, project: string, lineText: string): PhrenResult<string>;
|
|
81
|
+
/** Edit a queue item's text in review.md and the corresponding finding in FINDINGS.md. */
|
|
82
|
+
export declare function editQueueItem(phrenPath: string, project: string, lineText: string, newText: string): PhrenResult<string>;
|
|
83
|
+
export declare function readReviewQueueAcrossProjects(phrenPath: string, profile?: string): PhrenResult<ProjectQueueItem[]>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type PhrenResult } from "../shared.js";
|
|
2
|
+
export type TaskSection = "Active" | "Queue" | "Done";
|
|
3
|
+
export declare const TASKS_FILENAME = "tasks.md";
|
|
4
|
+
export declare const TASK_FILE_ALIASES: readonly ["tasks.md"];
|
|
5
|
+
export interface TaskItem {
|
|
6
|
+
/** Positional ID for display (e.g. "A1", "Q3"). Recomputed on every read — use stableId for persistent references. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Content-addressed stable ID embedded in the file as `<!-- bid:HASH -->`. Survives reordering and completions. */
|
|
9
|
+
stableId?: string;
|
|
10
|
+
section: TaskSection;
|
|
11
|
+
line: string;
|
|
12
|
+
checked: boolean;
|
|
13
|
+
priority?: "high" | "medium" | "low";
|
|
14
|
+
context?: string;
|
|
15
|
+
pinned?: boolean;
|
|
16
|
+
githubIssue?: number;
|
|
17
|
+
githubUrl?: string;
|
|
18
|
+
rank?: number;
|
|
19
|
+
lastActivity?: string;
|
|
20
|
+
createdAt?: string;
|
|
21
|
+
sessionId?: string;
|
|
22
|
+
scope?: string;
|
|
23
|
+
childFindings?: string[];
|
|
24
|
+
speculative?: boolean;
|
|
25
|
+
parentFinding?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TaskDoc {
|
|
28
|
+
project: string;
|
|
29
|
+
title: string;
|
|
30
|
+
items: Record<TaskSection, TaskItem[]>;
|
|
31
|
+
issues: string[];
|
|
32
|
+
path: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Apply gravity to tasks: items with stale lastActivity drift toward higher rank numbers.
|
|
36
|
+
* Only affects display order — does not mutate the file.
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyGravity(items: TaskItem[]): TaskItem[];
|
|
39
|
+
export declare function canonicalTaskFilePath(phrenPath: string, project: string): string | null;
|
|
40
|
+
export declare function isTaskFileName(filename: string): boolean;
|
|
41
|
+
export declare function resolveTaskFilePath(phrenPath: string, project: string): string | null;
|
|
42
|
+
export declare function readTasks(phrenPath: string, project: string): PhrenResult<TaskDoc>;
|
|
43
|
+
export declare function readTasksAcrossProjects(phrenPath: string, profile?: string): TaskDoc[];
|
|
44
|
+
export declare function resolveTaskItem(phrenPath: string, project: string, match: string): PhrenResult<TaskItem>;
|
|
45
|
+
export interface AddTaskOptions {
|
|
46
|
+
createdAt?: string;
|
|
47
|
+
sessionId?: string;
|
|
48
|
+
scope?: string;
|
|
49
|
+
speculative?: boolean;
|
|
50
|
+
parentFinding?: string;
|
|
51
|
+
}
|
|
52
|
+
export declare function addTask(phrenPath: string, project: string, item: string, opts?: AddTaskOptions): PhrenResult<TaskItem>;
|
|
53
|
+
export declare function addTasks(phrenPath: string, project: string, items: string[], opts?: Pick<AddTaskOptions, "scope">): PhrenResult<{
|
|
54
|
+
added: string[];
|
|
55
|
+
errors: string[];
|
|
56
|
+
}>;
|
|
57
|
+
export declare function completeTasks(phrenPath: string, project: string, matches: string[]): PhrenResult<{
|
|
58
|
+
completed: string[];
|
|
59
|
+
errors: string[];
|
|
60
|
+
}>;
|
|
61
|
+
export declare function completeTask(phrenPath: string, project: string, match: string): PhrenResult<string>;
|
|
62
|
+
export declare function removeTask(phrenPath: string, project: string, match: string): PhrenResult<string>;
|
|
63
|
+
export declare function removeTasks(phrenPath: string, project: string, matches: string[]): PhrenResult<{
|
|
64
|
+
removed: string[];
|
|
65
|
+
errors: string[];
|
|
66
|
+
}>;
|
|
67
|
+
export declare function updateTask(phrenPath: string, project: string, match: string, updates: {
|
|
68
|
+
text?: string;
|
|
69
|
+
priority?: string;
|
|
70
|
+
context?: string;
|
|
71
|
+
replace_context?: boolean;
|
|
72
|
+
section?: string;
|
|
73
|
+
github_issue?: number | string;
|
|
74
|
+
github_url?: string;
|
|
75
|
+
unlink_github?: boolean;
|
|
76
|
+
}): PhrenResult<string>;
|
|
77
|
+
export declare function pinTask(phrenPath: string, project: string, match: string): PhrenResult<string>;
|
|
78
|
+
export declare function unpinTask(phrenPath: string, project: string, match: string): PhrenResult<string>;
|
|
79
|
+
export declare function reorderTask(phrenPath: string, project: string, match: string, targetRank: number): PhrenResult<string>;
|
|
80
|
+
export declare function appendChildFinding(phrenPath: string, project: string, match: string, findingId: string): PhrenResult<string>;
|
|
81
|
+
export declare function promoteTask(phrenPath: string, project: string, match: string, moveToActive: boolean): PhrenResult<TaskItem>;
|
|
82
|
+
export declare function workNextTask(phrenPath: string, project: string): PhrenResult<string>;
|
|
83
|
+
export declare function tidyDoneTasks(phrenPath: string, project: string, keep?: number, dryRun?: boolean): PhrenResult<string>;
|
|
84
|
+
export declare function taskMarkdown(doc: TaskDoc): string;
|
|
85
|
+
export declare function linkTaskIssue(phrenPath: string, project: string, match: string, link: {
|
|
86
|
+
github_issue?: number | string;
|
|
87
|
+
github_url?: string;
|
|
88
|
+
unlink?: boolean;
|
|
89
|
+
}): PhrenResult<TaskItem>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { SqlJsDatabase } from "./index-query.js";
|
|
2
|
+
interface SqlJsStatic {
|
|
3
|
+
Database: new (data?: ArrayLike<number>) => SqlJsDatabase;
|
|
4
|
+
}
|
|
5
|
+
/** Encode a number[] embedding into a compact binary blob (Float32Array). */
|
|
6
|
+
declare function encodeEmbedding(embedding: number[]): Buffer;
|
|
7
|
+
/** Decode a binary blob back to number[]. */
|
|
8
|
+
declare function decodeEmbedding(blob: Uint8Array): number[];
|
|
9
|
+
export declare function setSqlJsLoaderForTests(loader: () => Promise<SqlJsStatic>): void;
|
|
10
|
+
export declare function resetSqlJsStateForTests(): void;
|
|
11
|
+
declare function openCacheDb(phrenPath: string): Promise<SqlJsDatabase>;
|
|
12
|
+
/**
|
|
13
|
+
* Q14: Persist the in-memory DB to disk under a file lock.
|
|
14
|
+
* Reads the current on-disk snapshot inside the lock, merges any entries that
|
|
15
|
+
* are in `db` but missing from disk, then writes atomically via temp-file rename.
|
|
16
|
+
* This prevents the "last writer wins" race where two concurrent processes each
|
|
17
|
+
* open the same on-disk snapshot, insert different entries, and overwrite each
|
|
18
|
+
* other's work.
|
|
19
|
+
*/
|
|
20
|
+
declare function persistDb(phrenPath: string, db: SqlJsDatabase): void;
|
|
21
|
+
declare function lookupCache(db: SqlJsDatabase, model: string, hash: string): number[] | null;
|
|
22
|
+
declare function insertCache(db: SqlJsDatabase, model: string, hash: string, embedding: number[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get embedding from OpenAI-compatible API.
|
|
25
|
+
* Calls POST https://api.openai.com/v1/embeddings (or compatible endpoint).
|
|
26
|
+
*/
|
|
27
|
+
declare function getApiEmbedding(text: string, apiKey: string, model?: string): Promise<number[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Get embeddings for multiple texts in a single API call.
|
|
30
|
+
* The OpenAI embeddings API supports array input natively.
|
|
31
|
+
*/
|
|
32
|
+
declare function getApiEmbeddings(texts: string[], apiKey: string, model?: string): Promise<number[][]>;
|
|
33
|
+
export declare const embeddingOps: {
|
|
34
|
+
openCacheDb: typeof openCacheDb;
|
|
35
|
+
persistDb: typeof persistDb;
|
|
36
|
+
lookupCache: typeof lookupCache;
|
|
37
|
+
insertCache: typeof insertCache;
|
|
38
|
+
getApiEmbedding: typeof getApiEmbedding;
|
|
39
|
+
getApiEmbeddings: typeof getApiEmbeddings;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Get embedding with caching. Uses the configured provider.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getCachedEmbedding(phrenPath: string, text: string, apiKey: string, model: string): Promise<number[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Get embeddings for multiple texts with caching. Batches uncached texts into single API calls.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getCachedEmbeddings(phrenPath: string, texts: string[], apiKey: string, model: string): Promise<number[][]>;
|
|
49
|
+
/**
|
|
50
|
+
* Compute cosine similarity between two vectors.
|
|
51
|
+
*/
|
|
52
|
+
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
53
|
+
export type { SqlJsDatabase } from "./index-query.js";
|
|
54
|
+
export { encodeEmbedding, decodeEmbedding, openCacheDb };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runTopLevelCommand(argv: string[]): Promise<boolean>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface TaskReferenceResolution {
|
|
2
|
+
stableId?: string;
|
|
3
|
+
error?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function resolveFindingTaskReference(phrenPath: string, project: string, match: string): TaskReferenceResolution;
|
|
6
|
+
export declare function resolveAutoFindingTaskItem(phrenPath: string, project: string): string | undefined;
|
|
7
|
+
export declare function resolveFindingSessionId(phrenPath: string, project: string, explicitSessionId?: string): string | undefined;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ImpactLogInput {
|
|
2
|
+
findingId: string;
|
|
3
|
+
project: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function findingIdFromLine(line: string): string;
|
|
7
|
+
export declare function extractFindingIdsFromSnippet(snippet: string): string[];
|
|
8
|
+
export declare function logImpact(phrenPath: string, entries: ImpactLogInput[]): void;
|
|
9
|
+
export declare function getHighImpactFindings(phrenPath: string, minSurfaceCount?: number): Set<string>;
|
|
10
|
+
export declare function markImpactEntriesCompletedForSession(phrenPath: string, sessionId: string, project?: string): number;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PhrenResult } from "../shared.js";
|
|
2
|
+
import type { FindingProvenanceSource } from "../content/citation.js";
|
|
3
|
+
interface FindingJournalCompactResult {
|
|
4
|
+
filesProcessed: number;
|
|
5
|
+
entriesProcessed: number;
|
|
6
|
+
added: number;
|
|
7
|
+
skipped: number;
|
|
8
|
+
failed: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function appendFindingJournal(phrenPath: string, project: string, text: string, opts?: {
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
repo?: string;
|
|
13
|
+
commit?: string;
|
|
14
|
+
file?: string;
|
|
15
|
+
source?: FindingProvenanceSource;
|
|
16
|
+
}): PhrenResult<string>;
|
|
17
|
+
export declare function compactFindingJournals(phrenPath: string, project?: string): FindingJournalCompactResult;
|
|
18
|
+
/**
|
|
19
|
+
* Append a finding to a team store's journal.
|
|
20
|
+
* Each actor gets one file per day — no merge conflicts possible.
|
|
21
|
+
* These are markdown files committed to git (not runtime JSONL).
|
|
22
|
+
*/
|
|
23
|
+
export declare function appendTeamJournal(storePath: string, project: string, finding: string, actor?: string): PhrenResult<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Read all team journal entries for a project, newest first.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readTeamJournalEntries(storePath: string, project: string): Array<{
|
|
28
|
+
file: string;
|
|
29
|
+
date: string;
|
|
30
|
+
actor: string;
|
|
31
|
+
entries: string[];
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Materialize FINDINGS.md from team journal entries.
|
|
35
|
+
* Groups by date, includes actor attribution.
|
|
36
|
+
*/
|
|
37
|
+
export declare function materializeTeamFindings(storePath: string, project: string): PhrenResult<{
|
|
38
|
+
entryCount: number;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type PhrenResult } from "../phren-core.js";
|
|
2
|
+
export declare const FINDING_TYPE_DECAY: Record<string, {
|
|
3
|
+
maxAgeDays: number;
|
|
4
|
+
decayMultiplier: number;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function extractFindingType(line: string): string | null;
|
|
7
|
+
export declare const FINDING_LIFECYCLE_STATUSES: readonly ["active", "superseded", "contradicted", "stale", "invalid_citation", "retracted"];
|
|
8
|
+
export type FindingLifecycleStatus = typeof FINDING_LIFECYCLE_STATUSES[number];
|
|
9
|
+
export interface FindingLifecycleMetadata {
|
|
10
|
+
status: FindingLifecycleStatus;
|
|
11
|
+
status_updated?: string;
|
|
12
|
+
status_reason?: string;
|
|
13
|
+
status_ref?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function parseFindingLifecycle(line: string): FindingLifecycleMetadata;
|
|
16
|
+
export declare function buildLifecycleComments(lifecycle: Partial<FindingLifecycleMetadata> | undefined, fallbackDate?: string): string;
|
|
17
|
+
export declare function stripLifecycleComments(line: string): string;
|
|
18
|
+
export declare function isInactiveFindingLine(line: string): boolean;
|
|
19
|
+
export type ContradictionResolution = "keep_a" | "keep_b" | "keep_both" | "retract_both";
|
|
20
|
+
export declare function supersedeFinding(phrenPath: string, project: string, findingText: string, supersededBy: string): PhrenResult<{
|
|
21
|
+
finding: string;
|
|
22
|
+
superseded_by: string;
|
|
23
|
+
status: FindingLifecycleStatus;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function retractFinding(phrenPath: string, project: string, findingText: string, reason: string): PhrenResult<{
|
|
26
|
+
finding: string;
|
|
27
|
+
reason: string;
|
|
28
|
+
status: FindingLifecycleStatus;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function resolveFindingContradiction(phrenPath: string, project: string, findingA: string, findingB: string, resolution: ContradictionResolution): PhrenResult<{
|
|
31
|
+
resolution: ContradictionResolution;
|
|
32
|
+
finding_a: {
|
|
33
|
+
text: string;
|
|
34
|
+
status: FindingLifecycleStatus;
|
|
35
|
+
};
|
|
36
|
+
finding_b: {
|
|
37
|
+
text: string;
|
|
38
|
+
status: FindingLifecycleStatus;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function recordRetrieval(phrenPath: string, file: string, section: string): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function withFileLock<T>(filePath: string, fn: () => T): T extends Promise<infer U> ? Promise<U> : T;
|
|
2
|
+
export declare function isFiniteNumber(value: unknown): value is number;
|
|
3
|
+
export declare function hasValidSchemaVersion(data: Record<string, unknown>): boolean;
|