@phren/cli 0.0.57 → 0.1.0
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/LICENSE +21 -0
- 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 +53 -19
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ala Arab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ACTION_KEYS, type ActionKey, type CapabilityEntry, type CapabilityManifest } from "./types.js";
|
|
2
|
+
export { cliManifest } from "./cli.js";
|
|
3
|
+
export { mcpManifest } from "./mcp.js";
|
|
4
|
+
export { vscodeManifest } from "./vscode.js";
|
|
5
|
+
export { webUiManifest } from "./web-ui.js";
|
|
6
|
+
import type { CapabilityManifest } from "./types.js";
|
|
7
|
+
export declare const ALL_MANIFESTS: CapabilityManifest[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const ACTION_KEYS: readonly ["finding.add", "finding.remove", "finding.list", "finding.filter_by_date", "finding.pin", "task.add", "task.complete", "task.remove", "task.update", "task.list", "task.pin", "task.github_link", "hook.list", "hook.toggle", "hook.toggle_per_project", "hook.custom_crud", "hook.errors", "search.fts", "search.fragment", "search.related_docs", "search.history", "graph.read", "graph.visualize", "graph.link_findings", "config.get", "config.set", "health.check", "health.doctor_fix", "health.sync", "session.start", "session.end", "skill.list", "skill.read", "skill.enable", "skill.write", "project.list", "project.manage", "project.summary", "export.project", "import.project", "profile.switch", "profile.list"];
|
|
2
|
+
export type ActionKey = typeof ACTION_KEYS[number];
|
|
3
|
+
export interface CapabilityEntry {
|
|
4
|
+
implemented: boolean;
|
|
5
|
+
handler?: string;
|
|
6
|
+
reason?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CapabilityManifest {
|
|
9
|
+
surface: "cli" | "mcp" | "vscode" | "web-ui";
|
|
10
|
+
version: string;
|
|
11
|
+
actions: Record<ActionKey, CapabilityEntry>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type SearchOptions } from "./search.js";
|
|
2
|
+
export declare function handleSearch(opts: SearchOptions, profile: string): Promise<void>;
|
|
3
|
+
export declare function handleFragmentSearch(args: string[], profile: string): Promise<void>;
|
|
4
|
+
export declare function handleRelatedDocs(args: string[], profile: string): Promise<void>;
|
|
5
|
+
export declare function handleAddFinding(project: string, learning: string): Promise<void>;
|
|
6
|
+
export declare function handlePinCanonical(project: string, memory: string): Promise<void>;
|
|
7
|
+
export declare function handleTruths(project: string): Promise<void>;
|
|
8
|
+
export declare function handleDoctor(args: string[]): Promise<void>;
|
|
9
|
+
export declare function handleStatus(): Promise<void>;
|
|
10
|
+
export declare function handleQualityFeedback(args: string[]): Promise<void>;
|
|
11
|
+
export declare function handleMemoryUi(args: string[]): Promise<void>;
|
|
12
|
+
export declare function handleShell(args: string[], profile: string): Promise<void>;
|
|
13
|
+
export declare function handleUpdate(args: string[]): Promise<void>;
|
|
14
|
+
export declare function handleReview(args: string[]): Promise<void>;
|
|
15
|
+
export declare function handleConsolidationStatus(args: string[]): Promise<void>;
|
|
16
|
+
export declare function handleSessionContext(): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { detectTaskIntent, parseHookInput, applyTrustFilter, rankResults, selectSnippets, buildHookOutput, trackSessionMetrics, filterTaskByPriority, parseCitations, validateCitation, annotateStale, getProjectGlobBoost, clearProjectGlobCache, clearCitationValidCache, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, type HookPromptInput, type SelectedSnippet, } from "./hooks.js";
|
|
2
|
+
export { scoreFindingCandidate } from "./extract.js";
|
|
3
|
+
export declare function runCliCommand(command: string, args: string[]): Promise<void | import("./govern.js").GovernanceSummary>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type FindingSensitivityLevel } from "../shared/governance.js";
|
|
2
|
+
export declare function checkProjectInProfile(phrenPath: string, project: string): string | null;
|
|
3
|
+
export declare function buildProactivitySnapshot(phrenPath: string): {
|
|
4
|
+
path: string;
|
|
5
|
+
configured: {
|
|
6
|
+
proactivity: "high" | "medium" | "low" | null;
|
|
7
|
+
proactivityFindings: "high" | "medium" | "low" | null;
|
|
8
|
+
proactivityTask: "high" | "medium" | "low" | null;
|
|
9
|
+
};
|
|
10
|
+
effective: {
|
|
11
|
+
proactivity: "high" | "medium" | "low";
|
|
12
|
+
proactivityFindings: "high" | "medium" | "low";
|
|
13
|
+
proactivityTask: "high" | "medium" | "low";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function handleConfig(args: string[]): Promise<void>;
|
|
17
|
+
export declare const FINDING_SENSITIVITY_CONFIG: Record<FindingSensitivityLevel, {
|
|
18
|
+
sessionCap: number;
|
|
19
|
+
proactivityFindings: string;
|
|
20
|
+
agentInstruction: string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function handleIndexPolicy(args: string[]): Promise<void>;
|
|
23
|
+
export declare function handleRetentionPolicy(args: string[]): Promise<void>;
|
|
24
|
+
export declare function handleWorkflowPolicy(args: string[]): Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FindingProvenanceSource } from "../content/citation.js";
|
|
2
|
+
export declare function parseGitLogRecords(cwd: string, days: number): Array<{
|
|
3
|
+
hash: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
body: string;
|
|
6
|
+
}>;
|
|
7
|
+
interface Candidate {
|
|
8
|
+
text: string;
|
|
9
|
+
score: number;
|
|
10
|
+
commit?: string;
|
|
11
|
+
file?: string;
|
|
12
|
+
sourceText?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function runGhJson<T>(cwd: string, args: string[]): Promise<T | null>;
|
|
15
|
+
export declare function ghCachePath(repoRoot: string): string;
|
|
16
|
+
export declare function mineGithubCandidates(repoRoot: string): Promise<Candidate[]>;
|
|
17
|
+
export declare function scoreFindingCandidate(subject: string, body: string): {
|
|
18
|
+
score: number;
|
|
19
|
+
text: string;
|
|
20
|
+
} | null;
|
|
21
|
+
export declare function handleExtractMemories(projectArg?: string, cwdArg?: string, silent?: boolean, sessionId?: string, source?: FindingProvenanceSource): Promise<void>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface GovernanceSummary {
|
|
2
|
+
projects: number;
|
|
3
|
+
staleCount: number;
|
|
4
|
+
conflictCount: number;
|
|
5
|
+
reviewCount: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function handleGovernMemories(projectArg?: string, silent?: boolean, dryRun?: boolean): Promise<GovernanceSummary>;
|
|
8
|
+
export declare function handlePruneMemories(args?: string[]): Promise<void>;
|
|
9
|
+
export declare function handleConsolidateMemories(args?: string[]): Promise<void>;
|
|
10
|
+
export declare function handleMaintain(args: string[]): Promise<void | GovernanceSummary>;
|
|
11
|
+
export declare function handleBackgroundMaintenance(projectArg?: string): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI: phren graph [--project <name>] [--limit <n>]
|
|
3
|
+
* Displays the fragment knowledge graph as a table.
|
|
4
|
+
*/
|
|
5
|
+
export declare function handleGraphRead(args: string[]): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* CLI: phren graph link <project> <finding_text> <fragment_name>
|
|
8
|
+
* Links a finding to a fragment manually.
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleGraphLink(args: string[]): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* CLI: phren graph <subcommand>
|
|
13
|
+
* Routes graph subcommands.
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleGraphNamespace(args: string[]): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FindingCitation } from "../content/citation.js";
|
|
2
|
+
export declare function clearCitationValidCache(): void;
|
|
3
|
+
export interface ParsedCitation {
|
|
4
|
+
citation?: FindingCitation;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseCitations(text: string): ParsedCitation[];
|
|
7
|
+
export declare function validateCitation(citation: ParsedCitation): boolean;
|
|
8
|
+
export declare function annotateStale(snippet: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { readRootManifest } from "../shared.js";
|
|
2
|
+
export interface HookContext {
|
|
3
|
+
phrenPath: string;
|
|
4
|
+
profile: string;
|
|
5
|
+
cwd: string;
|
|
6
|
+
hookTool: string;
|
|
7
|
+
activeProject: string | null;
|
|
8
|
+
hooksEnabled: boolean;
|
|
9
|
+
toolHookEnabled: boolean;
|
|
10
|
+
manifest: ReturnType<typeof readRootManifest>;
|
|
11
|
+
}
|
|
12
|
+
/** Build a HookContext from the current process environment. */
|
|
13
|
+
export declare function buildHookContext(): HookContext;
|
|
14
|
+
export type HookEvent = "SessionStart" | "Stop" | "UserPromptSubmit" | "PostToolUse";
|
|
15
|
+
/** Check common hook guards. Returns a reason string if the hook should NOT run, null if OK. */
|
|
16
|
+
export declare function checkHookGuard(ctx: HookContext, event: HookEvent): string | null;
|
|
17
|
+
/** Log a guard skip and optionally update runtime health. */
|
|
18
|
+
export declare function handleGuardSkip(ctx: HookContext, hookName: string, reason: string, healthUpdate?: Record<string, unknown>): void;
|
|
19
|
+
export { debugLog, appendAuditLog, getPhrenPath, readRootManifest, sessionMarker, runtimeFile, EXEC_TIMEOUT_MS, getProjectDirs, findProjectNameCaseInsensitive, homePath, } from "../shared.js";
|
|
20
|
+
export { updateRuntimeHealth, buildSyncStatus, getWorkflowPolicy, withFileLock, appendReviewQueue, recordFeedback, getQualityMultiplier, } from "../shared/governance.js";
|
|
21
|
+
export { detectProject } from "../shared/index.js";
|
|
22
|
+
export { isProjectHookEnabled, readProjectConfig, getProjectSourcePath } from "../project-config.js";
|
|
23
|
+
export { resolveRuntimeProfile } from "../runtime-profile.js";
|
|
24
|
+
export { detectProjectDir, ensureLocalGitRepo, isProjectTracked, repairPreexistingInstall, } from "../init/setup.js";
|
|
25
|
+
export { getProactivityLevelForTask, getProactivityLevelForFindings } from "../proactivity.js";
|
|
26
|
+
export { hasExplicitFindingSignal, shouldAutoCaptureFindingsForLevel } from "../proactivity.js";
|
|
27
|
+
export { FINDING_SENSITIVITY_CONFIG } from "./config.js";
|
|
28
|
+
export { isFeatureEnabled, errorMessage } from "../utils.js";
|
|
29
|
+
export { bootstrapPhrenDotEnv } from "../phren-dotenv.js";
|
|
30
|
+
export { finalizeTaskSession } from "../task/lifecycle.js";
|
|
31
|
+
export { appendFindingJournal } from "../finding/journal.js";
|
|
32
|
+
export { getHooksEnabledPreference } from "../init/init.js";
|
|
33
|
+
export { isToolHookEnabled } from "../hooks.js";
|
|
34
|
+
export { runDoctor } from "../link/link.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { SelectedSnippet, GitContext } from "../shared/retrieval.js";
|
|
2
|
+
export declare function buildHookOutput(selected: SelectedSnippet[], usedTokens: number, intent: string, gitCtx: GitContext | null, detectedProject: string | null, stage: Record<string, number>, tokenBudget: number, phrenPathLocal: string, sessionId?: string): string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SelectedSnippet } from "../shared/retrieval.js";
|
|
2
|
+
export type { HookContext } from "./hooks-context.js";
|
|
3
|
+
export { buildHookContext, handleGuardSkip } from "./hooks-context.js";
|
|
4
|
+
export declare function getUntrackedProjectNotice(phrenPath: string, cwd: string): string | null;
|
|
5
|
+
export declare function getSessionStartOnboardingNotice(phrenPath: string, cwd: string, activeProject: string | null): string | null;
|
|
6
|
+
export interface GitContext {
|
|
7
|
+
branch: string;
|
|
8
|
+
changedFiles: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
export declare function getGitContext(cwd?: string): GitContext | null;
|
|
11
|
+
export declare function trackSessionMetrics(phrenPathLocal: string, sessionId: string, selected: SelectedSnippet[]): void;
|
|
12
|
+
export declare function resolveSubprocessArgs(command: string): string[] | null;
|
|
13
|
+
export declare function handleHookSessionStart(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Extract potential insights from conversation text using keyword heuristics.
|
|
16
|
+
* Returns lines that contain insight-signal words and look like actionable knowledge.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractConversationInsights(text: string): string[];
|
|
19
|
+
export declare function filterConversationInsightsForProactivity(insights: string[], level?: "high" | "medium" | "low"): string[];
|
|
20
|
+
export declare function handleHookStop(): Promise<void>;
|
|
21
|
+
export declare function handleBackgroundSync(): Promise<void>;
|
|
22
|
+
export declare function handleHookContext(): Promise<void>;
|
|
23
|
+
export declare function handleHookTool(): Promise<void>;
|
|
24
|
+
interface LearningCandidate {
|
|
25
|
+
text: string;
|
|
26
|
+
confidence: number;
|
|
27
|
+
explicit?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function filterToolFindingsForProactivity(candidates: Array<{
|
|
30
|
+
text: string;
|
|
31
|
+
confidence: number;
|
|
32
|
+
explicit?: boolean;
|
|
33
|
+
}>, level?: "high" | "medium" | "low"): Array<{
|
|
34
|
+
text: string;
|
|
35
|
+
confidence: number;
|
|
36
|
+
explicit?: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
export declare function extractToolFindings(toolName: string, input: Record<string, unknown>, responseStr: string): LearningCandidate[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { parseCitations, validateCitation, annotateStale, clearCitationValidCache, type ParsedCitation, } from "./hooks-citations.js";
|
|
2
|
+
export { getProjectGlobBoost, clearProjectGlobCache, } from "./hooks-globs.js";
|
|
3
|
+
export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, selectSnippets, type SelectedSnippet, } from "../shared/retrieval.js";
|
|
4
|
+
export { buildHookOutput, } from "./hooks-output.js";
|
|
5
|
+
export { handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, trackSessionMetrics, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, resolveSubprocessArgs, } from "./hooks-session.js";
|
|
6
|
+
export interface HookPromptInput {
|
|
7
|
+
prompt: string;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseHookInput(raw: string): HookPromptInput | null;
|
|
12
|
+
export declare function handleHookPrompt(): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function handleSkillsNamespace(args: string[], profile: string): void;
|
|
2
|
+
export declare function handleHooksNamespace(args: string[]): void;
|
|
3
|
+
export declare function handleSkillList(profile: string, project?: string): void;
|
|
4
|
+
export declare function handleDetectSkills(args: string[], profile: string): void;
|
|
5
|
+
export declare function handleProjectsNamespace(args: string[], profile: string): Promise<void>;
|
|
6
|
+
export declare function handleTaskNamespace(args: string[]): Promise<void>;
|
|
7
|
+
export declare function handleFindingNamespace(args: string[]): Promise<void>;
|
|
8
|
+
export declare function handleStoreNamespace(args: string[]): Promise<void>;
|
|
9
|
+
export declare function handleProfileNamespace(args: string[]): void;
|
|
10
|
+
export declare function handlePromoteNamespace(args: string[]): Promise<void>;
|
|
11
|
+
export declare function handleReviewNamespace(args: string[]): Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function handleTaskView(profile: string): void;
|
|
2
|
+
export declare function handleSessionsView(args: string[]): Promise<void>;
|
|
3
|
+
export declare function handleQuickstart(): Promise<void>;
|
|
4
|
+
export declare function handleDebugInjection(args: string[], profile: string): Promise<void>;
|
|
5
|
+
export declare function handleInspectIndex(args: string[], profile: string): Promise<void>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface SearchOptions {
|
|
2
|
+
query: string;
|
|
3
|
+
limit: number;
|
|
4
|
+
project?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
showHistory?: boolean;
|
|
7
|
+
fromHistory?: number;
|
|
8
|
+
searchAll?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseSearchArgs(phrenPath: string, args: string[]): SearchOptions | null;
|
|
11
|
+
export declare function runSearch(opts: SearchOptions, phrenPath: string, profile: string): Promise<{
|
|
12
|
+
lines: string[];
|
|
13
|
+
exitCode: number;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function runFragmentSearch(query: string, phrenPath: string, profile: string, opts: {
|
|
16
|
+
project?: string;
|
|
17
|
+
limit?: number;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
lines: string[];
|
|
20
|
+
exitCode: number;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function parseFragmentSearchArgs(args: string[]): {
|
|
23
|
+
query: string;
|
|
24
|
+
project?: string;
|
|
25
|
+
limit?: number;
|
|
26
|
+
} | null;
|
|
27
|
+
export declare function runRelatedDocs(entity: string, phrenPath: string, profile: string, opts: {
|
|
28
|
+
project?: string;
|
|
29
|
+
limit?: number;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
lines: string[];
|
|
32
|
+
exitCode: number;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function parseRelatedDocsArgs(args: string[]): {
|
|
35
|
+
entity: string;
|
|
36
|
+
project?: string;
|
|
37
|
+
limit?: number;
|
|
38
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function handleTeamNamespace(args: string[]): Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SelectedSnippet } from "./shared/retrieval.js";
|
|
2
|
+
export interface GitContext {
|
|
3
|
+
branch: string;
|
|
4
|
+
changedFiles: Set<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function getGitContext(cwd?: string): GitContext | null;
|
|
7
|
+
export interface SessionMetric {
|
|
8
|
+
prompts: number;
|
|
9
|
+
keys: Record<string, number>;
|
|
10
|
+
lastChangedCount: number;
|
|
11
|
+
lastKeys: string[];
|
|
12
|
+
lastSeen?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseSessionMetrics(phrenPathLocal: string): Record<string, SessionMetric>;
|
|
15
|
+
export declare function writeSessionMetrics(phrenPathLocal: string, data: Record<string, SessionMetric>): void;
|
|
16
|
+
export declare function updateSessionMetrics(phrenPathLocal: string, updater: (data: Record<string, SessionMetric>) => void): void;
|
|
17
|
+
export declare function trackSessionMetrics(phrenPathLocal: string, sessionId: string, selected: SelectedSnippet[]): void;
|
|
18
|
+
export declare function isTransientGitError(message: string): boolean;
|
|
19
|
+
export declare function shouldRetryGitCommand(args: string[]): boolean;
|
|
20
|
+
export declare function runBestEffortGit(args: string[], cwd: string): Promise<{
|
|
21
|
+
ok: boolean;
|
|
22
|
+
output?: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function countUnsyncedCommits(cwd: string): Promise<number>;
|
|
26
|
+
export declare function isMergeableMarkdown(relPath: string): boolean;
|
|
27
|
+
export declare function snapshotLocalMergeableFiles(cwd: string): Promise<Map<string, string>>;
|
|
28
|
+
export declare function reconcileMergeableFiles(cwd: string, snapshots: Map<string, string>): Promise<boolean>;
|
|
29
|
+
export declare function recoverPushConflict(cwd: string): Promise<{
|
|
30
|
+
ok: boolean;
|
|
31
|
+
detail: string;
|
|
32
|
+
pullStatus: "ok" | "error";
|
|
33
|
+
pullDetail: string;
|
|
34
|
+
}>;
|
|
35
|
+
export declare function resolveSubprocessArgs(command: string): string[] | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function handleHookContext(): Promise<void>;
|
|
2
|
+
export declare function handleHookTool(): Promise<void>;
|
|
3
|
+
interface LearningCandidate {
|
|
4
|
+
text: string;
|
|
5
|
+
confidence: number;
|
|
6
|
+
explicit?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function filterToolFindingsForProactivity(candidates: Array<{
|
|
9
|
+
text: string;
|
|
10
|
+
confidence: number;
|
|
11
|
+
explicit?: boolean;
|
|
12
|
+
}>, level?: "high" | "medium" | "low"): Array<{
|
|
13
|
+
text: string;
|
|
14
|
+
confidence: number;
|
|
15
|
+
explicit?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function extractToolFindings(toolName: string, input: Record<string, unknown>, responseStr: string): LearningCandidate[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function getUntrackedProjectNotice(phrenPath: string, cwd: string): string | null;
|
|
2
|
+
export declare function getSessionStartOnboardingNotice(phrenPath: string, cwd: string, activeProject: string | null): string | null;
|
|
3
|
+
export declare function handleHookSessionStart(): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Read JSON from stdin if it's not a TTY. Returns null if stdin is a TTY or parsing fails. */
|
|
2
|
+
export declare function readStdinJson<T>(): T | null;
|
|
3
|
+
/**
|
|
4
|
+
* Extract potential insights from conversation text using keyword heuristics.
|
|
5
|
+
* Returns lines that contain insight-signal words and look like actionable knowledge.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractConversationInsights(text: string): string[];
|
|
8
|
+
export declare function filterConversationInsightsForProactivity(insights: string[], level?: "high" | "medium" | "low"): string[];
|
|
9
|
+
export declare function getSessionCap(): number;
|
|
10
|
+
export declare function handleHookStop(): Promise<void>;
|
|
11
|
+
export declare function handleBackgroundSync(): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PhrenResult } from "../shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Count active (non-archived) finding entries in FINDINGS.md content.
|
|
4
|
+
* Entries inside archive blocks are considered archived.
|
|
5
|
+
* Supports structured archive markers and HTML details blocks.
|
|
6
|
+
*/
|
|
7
|
+
export declare function countActiveFindings(content: string): number;
|
|
8
|
+
/**
|
|
9
|
+
* Archive the oldest entries from FINDINGS.md into reference/{topic}.md files.
|
|
10
|
+
* Keeps `keepCount` most recent entries, archives the rest grouped by topic.
|
|
11
|
+
* Returns the number of entries archived.
|
|
12
|
+
*/
|
|
13
|
+
export declare function autoArchiveToReference(phrenPath: string, project: string, keepCount: number): PhrenResult<number>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { RetentionPolicy } from "../shared/governance.js";
|
|
2
|
+
export interface FindingCitation {
|
|
3
|
+
created_at: string;
|
|
4
|
+
repo?: string;
|
|
5
|
+
file?: string;
|
|
6
|
+
line?: number;
|
|
7
|
+
commit?: string;
|
|
8
|
+
supersedes?: string;
|
|
9
|
+
task_item?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const FINDING_PROVENANCE_SOURCES: readonly ["human", "agent", "hook", "extract", "consolidation", "unknown"];
|
|
12
|
+
export type FindingProvenanceSource = (typeof FINDING_PROVENANCE_SOURCES)[number];
|
|
13
|
+
export declare function isFindingProvenanceSource(value: string | undefined): value is FindingProvenanceSource;
|
|
14
|
+
export interface FindingProvenance {
|
|
15
|
+
source?: FindingProvenanceSource;
|
|
16
|
+
machine?: string;
|
|
17
|
+
actor?: string;
|
|
18
|
+
tool?: string;
|
|
19
|
+
model?: string;
|
|
20
|
+
session_id?: string;
|
|
21
|
+
scope?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface FindingTrustIssue {
|
|
24
|
+
date: string;
|
|
25
|
+
bullet: string;
|
|
26
|
+
reason: "stale" | "invalid_citation";
|
|
27
|
+
}
|
|
28
|
+
export interface TrustFilterOptions {
|
|
29
|
+
ttlDays?: number;
|
|
30
|
+
minConfidence?: number;
|
|
31
|
+
decay?: Partial<RetentionPolicy["decay"]>;
|
|
32
|
+
project?: string;
|
|
33
|
+
highImpactFindingIds?: Set<string>;
|
|
34
|
+
}
|
|
35
|
+
export declare function getHeadCommit(cwd: string): string | undefined;
|
|
36
|
+
export declare function getRepoRoot(cwd: string): string | undefined;
|
|
37
|
+
export declare function inferCitationLocation(repoPath: string, commit: string): {
|
|
38
|
+
file?: string;
|
|
39
|
+
line?: number;
|
|
40
|
+
};
|
|
41
|
+
export declare function buildCitationComment(citation: FindingCitation): string;
|
|
42
|
+
export declare function buildSourceComment(source: FindingProvenance): string;
|
|
43
|
+
export declare function parseSourceComment(line: string): FindingProvenance | null;
|
|
44
|
+
export declare function parseCitationComment(line: string): FindingCitation | null;
|
|
45
|
+
export declare function validateFindingCitation(citation: FindingCitation): boolean;
|
|
46
|
+
export declare function filterTrustedFindings(content: string, ttlDays: number): string;
|
|
47
|
+
export declare function filterTrustedFindingsDetailed(content: string, opts: number | TrustFilterOptions): {
|
|
48
|
+
content: string;
|
|
49
|
+
issues: FindingTrustIssue[];
|
|
50
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare function callLlm(prompt: string, signal?: AbortSignal, maxTokens?: number): Promise<string>;
|
|
2
|
+
/**
|
|
3
|
+
* Strip all common finding metadata:
|
|
4
|
+
* - HTML comments: <!-- ... -->
|
|
5
|
+
* - "migrated from" annotations: (migrated from ...)
|
|
6
|
+
* - Leading bullet dash: "- " at the start of the string
|
|
7
|
+
*/
|
|
8
|
+
export declare function stripMetadata(s: string): string;
|
|
9
|
+
export declare function jaccardTokenize(text: string): Set<string>;
|
|
10
|
+
export declare function jaccardSimilarity(a: Set<string>, b: Set<string>): number;
|
|
11
|
+
/**
|
|
12
|
+
* Scan existing findings for proper nouns / tool names that appear in 2+ bullets.
|
|
13
|
+
* Results are cached in .runtime/project-entities-{project}.json (1h TTL or
|
|
14
|
+
* invalidated when FINDINGS.md changes).
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractDynamicEntities(phrenPath: string, project: string): Set<string>;
|
|
17
|
+
/** Returns existing learning lines that appear to conflict with newFinding. */
|
|
18
|
+
export declare function detectConflicts(newFinding: string, existingLines: string[], dynamicEntities?: Set<string>): string[];
|
|
19
|
+
export declare function isDuplicateFinding(existingContent: string, newLearning: string, threshold?: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Normalize known observation tags in learning text to lowercase.
|
|
22
|
+
* Returns the normalized text and a warning if unknown bracket tags are found.
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeObservationTags(text: string): {
|
|
25
|
+
text: string;
|
|
26
|
+
warning?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Scan text for secrets and PII patterns. Returns the type of secret found, or null if clean.
|
|
30
|
+
*/
|
|
31
|
+
export declare function scanForSecrets(text: string): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve coreferences in learning text by replacing vague pronouns with concrete names.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveCoref(text: string, context: {
|
|
36
|
+
project?: string;
|
|
37
|
+
file?: string;
|
|
38
|
+
}): string;
|
|
39
|
+
/**
|
|
40
|
+
* LLM-based semantic dedup check. Only called when PHREN_FEATURE_SEMANTIC_DEDUP=1.
|
|
41
|
+
* Must be called before addFindingToFile() since that function is sync.
|
|
42
|
+
* Returns true if the new learning is a semantic duplicate of any existing bullet.
|
|
43
|
+
*/
|
|
44
|
+
export declare function checkSemanticDedup(phrenPath: string, project: string, newLearning: string, signal?: AbortSignal): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* LLM-based conflict check. Only called when PHREN_FEATURE_SEMANTIC_CONFLICT=1.
|
|
47
|
+
* Call after detectConflicts() in addFindingToFile flow.
|
|
48
|
+
* Returns conflict annotations to append to the bullet.
|
|
49
|
+
* Also scans global findings and other projects for cross-project contradictions.
|
|
50
|
+
* Has a 30-second total timeout; returns partial results if the deadline is hit.
|
|
51
|
+
*/
|
|
52
|
+
export declare function checkSemanticConflicts(phrenPath: string, project: string, newFinding: string, signal?: AbortSignal): Promise<{
|
|
53
|
+
annotations: string[];
|
|
54
|
+
checked: boolean;
|
|
55
|
+
}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type PhrenResult } from "../shared.js";
|
|
2
|
+
import { type FindingCitation, type FindingProvenanceSource } from "./citation.js";
|
|
3
|
+
interface AddFindingOptions {
|
|
4
|
+
extraAnnotations?: string[];
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
source?: FindingProvenanceSource;
|
|
7
|
+
scope?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AddFindingResult {
|
|
10
|
+
message: string;
|
|
11
|
+
status: "added" | "created" | "skipped";
|
|
12
|
+
}
|
|
13
|
+
export declare function autoDetectFindingType(text: string): string | null;
|
|
14
|
+
export declare function upsertCanonical(phrenPath: string, project: string, memory: string): PhrenResult<string>;
|
|
15
|
+
export declare function addFindingToFile(phrenPath: string, project: string, learning: string, citationInput?: Partial<FindingCitation>, opts?: AddFindingOptions): PhrenResult<AddFindingResult>;
|
|
16
|
+
export declare function addFindingsToFile(phrenPath: string, project: string, learnings: string[], opts?: {
|
|
17
|
+
extraAnnotationsByFinding?: string[][];
|
|
18
|
+
sessionId?: string;
|
|
19
|
+
source?: FindingProvenanceSource;
|
|
20
|
+
scope?: string;
|
|
21
|
+
}): PhrenResult<{
|
|
22
|
+
added: string[];
|
|
23
|
+
skipped: string[];
|
|
24
|
+
rejected: {
|
|
25
|
+
text: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
}[];
|
|
28
|
+
}>;
|
|
29
|
+
export {};
|