@phren/cli 0.1.32 → 0.1.34
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 +2 -2
- package/dist/cli/config-access.d.ts +1 -0
- package/dist/cli/config-access.js +59 -0
- package/dist/cli/config-llm.d.ts +1 -0
- package/dist/cli/config-llm.js +60 -0
- package/dist/cli/config-policy.d.ts +11 -0
- package/dist/cli/config-policy.js +328 -0
- package/dist/cli/config-proactivity.d.ts +15 -0
- package/dist/cli/config-proactivity.js +135 -0
- package/dist/cli/config-shared.d.ts +6 -0
- package/dist/cli/config-shared.js +23 -0
- package/dist/cli/config-synonyms.d.ts +1 -0
- package/dist/cli/config-synonyms.js +63 -0
- package/dist/cli/config.d.ts +6 -24
- package/dist/cli/config.js +13 -670
- package/dist/cli/team.js +26 -13
- package/dist/content/dedup.js +25 -3
- package/dist/content/learning.js +10 -16
- package/dist/finding-graph-id.d.ts +15 -0
- package/dist/finding-graph-id.js +58 -0
- package/dist/generated/memory-ui-graph.browser.js +15 -15
- package/dist/governance/activity.d.ts +36 -0
- package/dist/governance/activity.js +83 -0
- package/dist/governance/rbac.d.ts +17 -0
- package/dist/governance/rbac.js +37 -1
- package/dist/governance/scores.js +26 -45
- package/dist/index.js +32 -1
- package/dist/memory-ui-graph.runtime.js +15 -15
- package/dist/phren-paths.d.ts +6 -0
- package/dist/phren-paths.js +8 -0
- package/dist/shared/governance.d.ts +1 -0
- package/dist/shared/governance.js +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +90 -17
- package/dist/shared/retrieval.js +25 -6
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +1 -1
- package/dist/telemetry.js +4 -1
- package/dist/tools/config.js +39 -2
- package/dist/tools/finding.d.ts +1 -0
- package/dist/tools/finding.js +40 -2
- package/dist/tools/search.js +28 -1
- package/dist/ui/data.d.ts +2 -0
- package/dist/ui/data.js +8 -3
- package/dist/ui/graph.js +2 -0
- package/dist/ui/page.js +45 -2
- package/dist/ui/scripts.d.ts +13 -0
- package/dist/ui/scripts.js +229 -2
- package/dist/ui/server.js +165 -1
- package/dist/ui/styles.d.ts +1 -0
- package/dist/ui/styles.js +38 -0
- package/package.json +3 -3
- package/dist/cli-hooks-prompt.d.ts +0 -18
- package/dist/cli-hooks-prompt.js +0 -359
- package/dist/cli-hooks-session-handlers.d.ts +0 -3
- package/dist/cli-hooks-session-handlers.js +0 -356
- package/dist/cli-hooks-stop.d.ts +0 -11
- package/dist/cli-hooks-stop.js +0 -584
- package/dist/init-bootstrap.d.ts +0 -5
- package/dist/init-bootstrap.js +0 -21
- package/dist/init-detect.d.ts +0 -8
- package/dist/init-detect.js +0 -38
- package/dist/init-env.d.ts +0 -6
- package/dist/init-env.js +0 -114
- package/dist/init-fresh.d.ts +0 -10
- package/dist/init-fresh.js +0 -234
- package/dist/init-hooks.d.ts +0 -5
- package/dist/init-hooks.js +0 -26
- package/dist/init-mcp.d.ts +0 -8
- package/dist/init-mcp.js +0 -65
- package/dist/init-modes.d.ts +0 -4
- package/dist/init-modes.js +0 -135
- package/dist/init-npm.d.ts +0 -10
- package/dist/init-npm.js +0 -37
- package/dist/init-project-local.d.ts +0 -2
- package/dist/init-project-local.js +0 -99
- package/dist/init-semantic.d.ts +0 -4
- package/dist/init-semantic.js +0 -48
- package/dist/init-types.d.ts +0 -59
- package/dist/init-types.js +0 -1
- package/dist/init-update.d.ts +0 -10
- package/dist/init-update.js +0 -96
package/dist/ui/styles.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export declare const PROJECT_REFERENCE_UI_STYLES = "\n .project-reference-shell
|
|
|
2
2
|
export declare const SETTINGS_TAB_UI_STYLES = "\n .settings-shell {\n display: flex;\n flex-direction: column;\n gap: 18px;\n }\n .settings-section {\n border: 1px solid var(--border);\n border-radius: var(--radius);\n background: var(--surface);\n box-shadow: var(--shadow);\n overflow: hidden;\n }\n .settings-section-findings { border-top: 3px solid color-mix(in srgb, var(--accent) 60%, var(--border)); }\n .settings-section-behavior { border-top: 3px solid color-mix(in srgb, var(--blue) 45%, var(--border)); }\n .settings-section-integrations { border-top: 3px solid color-mix(in srgb, var(--purple) 45%, var(--border)); }\n .settings-section-header {\n padding: 16px 18px 12px;\n border-bottom: 1px solid var(--border-light);\n background: var(--surface);\n }\n .settings-section-header h3 {\n margin: 0;\n font-size: var(--text-md);\n font-weight: 700;\n letter-spacing: -0.02em;\n color: var(--ink);\n }\n .settings-section-header p {\n margin: 6px 0 0;\n color: var(--muted);\n font-size: var(--text-sm);\n line-height: 1.5;\n }\n .settings-section-body {\n padding: 18px;\n display: flex;\n flex-direction: column;\n gap: 16px;\n }\n .settings-control {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n border: 1px solid var(--border-light);\n border-radius: var(--radius-sm);\n background: var(--surface-raised);\n }\n .settings-control-primary {\n background: color-mix(in srgb, var(--accent) 4%, var(--surface-raised));\n border-color: color-mix(in srgb, var(--accent) 18%, var(--border));\n }\n .settings-control-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n .settings-control-label {\n font-size: var(--text-base);\n font-weight: 600;\n color: var(--ink-secondary);\n }\n .settings-control-note {\n color: var(--muted);\n font-size: var(--text-sm);\n line-height: 1.5;\n }\n .settings-control-value {\n color: var(--ink-secondary);\n font-size: var(--text-base);\n font-weight: 600;\n }\n .settings-chip-row {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n }\n .settings-chip {\n border: 1px solid var(--border);\n background: transparent;\n color: var(--ink-secondary);\n border-radius: 999px;\n padding: 6px 12px;\n cursor: pointer;\n font-size: var(--text-sm);\n font-family: var(--font);\n font-weight: 600;\n transition: background .15s, border-color .15s, color .15s;\n }\n .settings-chip:hover {\n border-color: var(--accent);\n color: var(--ink);\n }\n .settings-chip.active {\n border-color: var(--accent);\n background: var(--accent);\n color: #fff;\n }\n .settings-chip.readonly {\n cursor: default;\n opacity: 0.92;\n }\n .settings-chip.readonly:hover {\n border-color: var(--border);\n color: var(--ink-secondary);\n }\n .settings-chip.active.readonly:hover {\n border-color: var(--accent);\n color: #fff;\n }\n .settings-status-inline {\n min-height: 18px;\n font-size: var(--text-sm);\n color: var(--muted);\n }\n .settings-status-inline.ok { color: var(--success); }\n .settings-status-inline.err { color: var(--danger); }\n .settings-integrations-table {\n width: 100%;\n border-collapse: collapse;\n }\n .settings-integrations-table th,\n .settings-integrations-table td {\n text-align: left;\n padding: 10px 8px;\n border-bottom: 1px solid var(--border-light);\n font-size: var(--text-sm);\n vertical-align: middle;\n }\n .settings-integrations-table th {\n color: var(--muted);\n font-weight: 650;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n font-size: var(--text-xs);\n }\n .settings-integrations-table tr:last-child td { border-bottom: none; }\n .settings-tool {\n display: flex;\n align-items: center;\n gap: 8px;\n font-weight: 600;\n color: var(--ink-secondary);\n text-transform: capitalize;\n }\n .settings-indicator {\n width: 9px;\n height: 9px;\n border-radius: 50%;\n display: inline-block;\n margin-right: 6px;\n }\n .settings-indicator.on { background: var(--success); }\n .settings-indicator.off { background: var(--danger); }\n";
|
|
3
3
|
export declare const TASK_UI_STYLES = "\n /* \u2500\u2500 Task Manager Styles \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n .task-toolbar {\n display: flex;\n align-items: center;\n gap: 12px;\n margin-bottom: 20px;\n flex-wrap: wrap;\n }\n .task-filter-select {\n border: 1px solid var(--border);\n border-radius: var(--radius-sm);\n padding: 8px 12px;\n background: var(--surface);\n color: var(--ink);\n font-size: var(--text-sm);\n font-family: var(--font);\n cursor: pointer;\n transition: border-color 0.15s;\n }\n .task-filter-select:hover { border-color: var(--accent); }\n .task-filter-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }\n .task-count-label {\n font-size: var(--text-sm);\n color: var(--muted);\n margin-left: auto;\n font-weight: 500;\n }\n\n .task-empty-state {\n padding: 60px 40px;\n text-align: center;\n color: var(--muted);\n }\n\n .task-add-bar {\n display: flex;\n gap: 10px;\n margin-bottom: 20px;\n align-items: center;\n }\n .task-add-input {\n flex: 1;\n padding: 10px 14px;\n border: 1px solid var(--border);\n border-radius: var(--radius-sm);\n background: var(--surface);\n color: var(--ink);\n font-size: var(--text-base);\n font-family: var(--font);\n transition: border-color 0.15s, box-shadow 0.15s;\n }\n .task-add-input:focus {\n outline: none;\n border-color: var(--accent);\n box-shadow: 0 0 0 3px var(--accent-dim);\n }\n .task-add-input::placeholder { color: var(--muted); opacity: 0.6; }\n .task-add-btn {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 10px 18px;\n border: none;\n border-radius: var(--radius-sm);\n background: var(--accent);\n color: #fff;\n cursor: pointer;\n font-size: var(--text-sm);\n font-weight: 600;\n font-family: var(--font);\n transition: background 0.15s, transform 0.1s;\n white-space: nowrap;\n }\n .task-add-btn:hover { background: var(--accent-hover); }\n .task-add-btn:active { transform: scale(0.97); }\n\n .task-section-group { margin-bottom: 24px; }\n .task-section-header {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--text-xs);\n font-weight: 700;\n color: var(--muted);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n margin-bottom: 8px;\n padding: 0 4px;\n }\n .task-section-count {\n font-weight: 500;\n color: var(--muted);\n font-size: var(--text-xs);\n opacity: 0.7;\n }\n\n .task-list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n border: 1px solid var(--border);\n border-radius: var(--radius);\n background: var(--surface);\n overflow: hidden;\n }\n\n .task-row {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n border-bottom: 1px solid var(--border-light);\n transition: background 0.1s;\n cursor: default;\n position: relative;\n }\n .task-row:last-child { border-bottom: none; }\n .task-row:hover { background: var(--surface-raised); }\n .task-row:hover .task-row-actions { opacity: 1; pointer-events: auto; }\n\n .task-row-priority {\n width: 4px;\n height: 24px;\n border-radius: 2px;\n flex-shrink: 0;\n }\n .task-row-priority-high { background: #ef4444; }\n .task-row-priority-medium { background: #f59e0b; }\n .task-row-priority-low { background: #9ca3af; }\n .task-row-priority-none { background: transparent; }\n\n .task-row-content {\n flex: 1;\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n .task-row-text {\n font-size: var(--text-base);\n color: var(--ink);\n line-height: 1.4;\n word-break: break-word;\n }\n .task-row-done .task-row-text {\n text-decoration: line-through;\n opacity: 0.5;\n }\n .task-row-context {\n font-size: var(--text-xs);\n color: var(--muted);\n font-style: italic;\n margin-top: 2px;\n }\n\n .task-row-meta {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-shrink: 0;\n }\n\n .task-priority-badge {\n display: inline-block;\n padding: 1px 7px;\n border-radius: 999px;\n font-size: 10px;\n font-weight: 600;\n text-transform: capitalize;\n }\n .task-priority-high { background: #ef444418; color: #ef4444; }\n .task-priority-medium { background: #f59e0b18; color: #f59e0b; }\n .task-priority-low { background: #6b728018; color: #6b7280; }\n\n .task-project-badge {\n display: inline-block;\n padding: 2px 8px;\n border-radius: var(--radius-sm);\n font-size: 10px;\n font-weight: 500;\n background: var(--accent-dim);\n color: var(--accent);\n }\n\n .task-pin-indicator {\n color: var(--accent);\n display: inline-flex;\n align-items: center;\n }\n\n .task-github-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 2px 8px;\n border-radius: var(--radius-sm);\n font-size: 10px;\n font-weight: 500;\n background: var(--surface-sunken);\n color: var(--ink-secondary);\n text-decoration: none;\n transition: background 0.15s;\n }\n .task-github-badge:hover { background: var(--accent-dim); color: var(--accent); }\n\n .task-row-actions {\n display: flex;\n align-items: center;\n gap: 4px;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s;\n flex-shrink: 0;\n }\n .task-action-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: 1px solid var(--border);\n border-radius: var(--radius-sm);\n background: var(--surface);\n color: var(--muted);\n cursor: pointer;\n font-size: 12px;\n font-family: var(--font);\n transition: all 0.15s;\n padding: 0;\n }\n .task-action-btn:hover {\n border-color: var(--accent);\n color: var(--accent);\n background: var(--accent-dim);\n }\n .task-action-btn.task-action-complete:hover {\n border-color: var(--success);\n color: var(--success);\n background: var(--success-dim);\n }\n .task-action-btn.task-action-delete:hover {\n border-color: var(--danger);\n color: var(--danger);\n background: var(--danger-dim);\n }\n\n .task-done-section { margin-top: 24px; }\n .task-done-toggle {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 4px;\n background: none;\n border: none;\n color: var(--muted);\n font-size: var(--text-xs);\n font-weight: 700;\n font-family: var(--font);\n cursor: pointer;\n text-transform: uppercase;\n letter-spacing: 0.06em;\n transition: color 0.15s;\n }\n .task-done-toggle:hover { color: var(--ink-secondary); }\n .task-toggle-arrow {\n font-size: 10px;\n transition: transform 0.2s;\n }\n .task-done-list { padding-top: 4px; }\n\n /* \u2500\u2500 Task Summary Bar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n .task-summary-bar {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n background: var(--surface-sunken, var(--surface));\n border: 1px solid var(--border);\n border-radius: var(--radius);\n margin-bottom: 16px;\n flex-wrap: wrap;\n font-size: var(--text-sm);\n }\n .task-summary-total {\n font-weight: 600;\n color: var(--ink);\n font-size: var(--text-base);\n }\n .task-summary-pill {\n display: inline-flex;\n align-items: center;\n padding: 2px 8px;\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n }\n .task-summary-high { background: #ef444422; color: #ef4444; }\n .task-summary-medium { background: #f59e0b22; color: #f59e0b; }\n .task-summary-low { background: #6b728022; color: #6b7280; }\n .task-summary-projects {\n display: flex;\n gap: 6px;\n align-items: center;\n }\n .task-summary-project {\n font-size: 11px;\n color: var(--muted);\n padding: 1px 6px;\n border: 1px solid var(--border);\n border-radius: var(--radius-sm);\n }\n\n /* \u2500\u2500 Task Session Badge \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n .task-session-badge {\n display: inline-block;\n padding: 1px 6px;\n border-radius: var(--radius-sm);\n font-size: 10px;\n font-family: var(--mono, monospace);\n background: var(--surface-sunken, var(--surface));\n color: var(--muted);\n border: 1px solid var(--border);\n }\n";
|
|
4
4
|
export declare const REVIEW_UI_STYLES = "\n /* \u2500\u2500 Review Toolbar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n .review-toolbar {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 16px;\n flex-wrap: wrap;\n }\n .review-flagged-toggle {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-size: var(--text-sm);\n font-weight: 500;\n color: var(--ink-secondary);\n cursor: pointer;\n user-select: none;\n }\n .review-flagged-toggle input[type=\"checkbox\"] {\n width: 14px;\n height: 14px;\n cursor: pointer;\n accent-color: var(--accent);\n }\n .review-sync-dot {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 22px;\n height: 22px;\n flex-shrink: 0;\n }\n .review-sync-indicator {\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--success);\n display: inline-block;\n transition: background 0.3s;\n }\n .review-sync-indicator.syncing {\n background: var(--warning);\n animation: ledPulse 1.2s infinite;\n }\n .review-sync-indicator.error {\n background: var(--danger);\n }\n /* \u2500\u2500 Review Card Highlight (keyboard shortcuts) \u2500\u2500\u2500\u2500 */\n .review-card-highlight {\n border: 2px solid var(--blue) !important;\n box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.08), var(--shadow) !important;\n background: color-mix(in srgb, var(--surface) 98%, var(--blue)) !important;\n }\n";
|
|
5
|
+
export declare const LAYOUT_VIEWPORT_STYLES = "\n /* Graph: fill the available viewport height instead of forcing 800px\n (which overflowed laptop-height screens), and frame it as a panel. */\n #graph-canvas {\n height: calc(100vh - 110px);\n min-height: 420px;\n }\n .graph-container {\n position: relative;\n border: 1px solid var(--border);\n border-radius: 10px;\n overflow: hidden;\n }\n\n /* Header nav: shrink and scroll internally on narrow widths so the header\n never pushes the page wider than the viewport. */\n .nav {\n min-width: 0;\n flex: 0 1 auto;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n .nav::-webkit-scrollbar { display: none; }\n .nav-item { flex: 0 0 auto; white-space: nowrap; }\n\n @media (max-width: 900px) {\n #graph-canvas { height: calc(100vh - 92px); min-height: 360px; }\n .header { gap: 12px; }\n .nav-item { padding: 0 12px; }\n }\n";
|
package/dist/ui/styles.js
CHANGED
|
@@ -662,3 +662,41 @@ export const REVIEW_UI_STYLES = `
|
|
|
662
662
|
background: color-mix(in srgb, var(--surface) 98%, var(--blue)) !important;
|
|
663
663
|
}
|
|
664
664
|
`;
|
|
665
|
+
/*
|
|
666
|
+
* Viewport refinements — appended LAST in the page <style> so these win the
|
|
667
|
+
* cascade over the base WEB_UI_STYLES. Keeps the layout fitting the viewport
|
|
668
|
+
* across desktop, laptop, and narrow widths without horizontal page scroll.
|
|
669
|
+
*/
|
|
670
|
+
export const LAYOUT_VIEWPORT_STYLES = `
|
|
671
|
+
/* Graph: fill the available viewport height instead of forcing 800px
|
|
672
|
+
(which overflowed laptop-height screens), and frame it as a panel. */
|
|
673
|
+
#graph-canvas {
|
|
674
|
+
height: calc(100vh - 110px);
|
|
675
|
+
min-height: 420px;
|
|
676
|
+
}
|
|
677
|
+
.graph-container {
|
|
678
|
+
position: relative;
|
|
679
|
+
border: 1px solid var(--border);
|
|
680
|
+
border-radius: 10px;
|
|
681
|
+
overflow: hidden;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/* Header nav: shrink and scroll internally on narrow widths so the header
|
|
685
|
+
never pushes the page wider than the viewport. */
|
|
686
|
+
.nav {
|
|
687
|
+
min-width: 0;
|
|
688
|
+
flex: 0 1 auto;
|
|
689
|
+
overflow-x: auto;
|
|
690
|
+
overflow-y: hidden;
|
|
691
|
+
scrollbar-width: none;
|
|
692
|
+
-ms-overflow-style: none;
|
|
693
|
+
}
|
|
694
|
+
.nav::-webkit-scrollbar { display: none; }
|
|
695
|
+
.nav-item { flex: 0 0 auto; white-space: nowrap; }
|
|
696
|
+
|
|
697
|
+
@media (max-width: 900px) {
|
|
698
|
+
#graph-canvas { height: calc(100vh - 92px); min-height: 360px; }
|
|
699
|
+
.header { gap: 12px; }
|
|
700
|
+
.nav-item { padding: 0 12px; }
|
|
701
|
+
}
|
|
702
|
+
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phren/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "Knowledge layer for AI agents — CLI, MCP server, and data layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"glob": "^13.0.6",
|
|
80
80
|
"graphology": "^0.26.0",
|
|
81
81
|
"graphology-layout-forceatlas2": "^0.10.1",
|
|
82
|
-
"inquirer": "^
|
|
83
|
-
"js-yaml": "^4.
|
|
82
|
+
"inquirer": "^14.0.2",
|
|
83
|
+
"js-yaml": "^4.2.0",
|
|
84
84
|
"sigma": "^3.0.3",
|
|
85
85
|
"sql.js-fts5": "^1.4.0",
|
|
86
86
|
"zod": "^4.4.3"
|
|
@@ -1,18 +0,0 @@
|
|
|
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, toolResponse?: unknown): LearningCandidate[];
|
|
18
|
-
export {};
|
package/dist/cli-hooks-prompt.js
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* handleHookContext (SessionStart context injection) and handleHookTool (PostToolUse)
|
|
3
|
-
* with tool finding extraction helpers.
|
|
4
|
-
* Extracted from cli-hooks-session.ts for modularity.
|
|
5
|
-
*/
|
|
6
|
-
import { buildHookContext, debugLog, runtimeFile, sessionMarker, getPhrenPath, appendAuditLog, appendReviewQueue, detectProject, isProjectHookEnabled, getProactivityLevelForFindings, errorMessage, } from "./cli/hooks-context.js";
|
|
7
|
-
import * as fs from "fs";
|
|
8
|
-
import * as path from "path";
|
|
9
|
-
import { buildIndex, queryRows, } from "./shared/index.js";
|
|
10
|
-
import { filterTaskByPriority } from "./shared/retrieval.js";
|
|
11
|
-
import { readStdinJson, getSessionCap } from "./cli-hooks-stop.js";
|
|
12
|
-
import { logger } from "./logger.js";
|
|
13
|
-
export async function handleHookContext() {
|
|
14
|
-
const ctx = buildHookContext();
|
|
15
|
-
if (!ctx.hooksEnabled) {
|
|
16
|
-
process.exit(0);
|
|
17
|
-
}
|
|
18
|
-
let cwd = ctx.cwd;
|
|
19
|
-
const ctxStdin = readStdinJson();
|
|
20
|
-
if (ctxStdin?.cwd)
|
|
21
|
-
cwd = ctxStdin.cwd;
|
|
22
|
-
const project = cwd !== ctx.cwd ? detectProject(ctx.phrenPath, cwd, ctx.profile) : ctx.activeProject;
|
|
23
|
-
if (!isProjectHookEnabled(ctx.phrenPath, project, "UserPromptSubmit")) {
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
const db = await buildIndex(ctx.phrenPath, ctx.profile);
|
|
27
|
-
const contextLabel = project ? `\u25c6 phren \u00b7 ${project} \u00b7 context` : `\u25c6 phren \u00b7 context`;
|
|
28
|
-
const parts = [contextLabel, "<phren-context>"];
|
|
29
|
-
if (project) {
|
|
30
|
-
const summaryRow = queryRows(db, "SELECT content FROM docs WHERE project = ? AND type = 'summary'", [project]);
|
|
31
|
-
if (summaryRow) {
|
|
32
|
-
parts.push(`# ${project}`);
|
|
33
|
-
parts.push(summaryRow[0][0]);
|
|
34
|
-
parts.push("");
|
|
35
|
-
}
|
|
36
|
-
const findingsRow = queryRows(db, "SELECT content FROM docs WHERE project = ? AND type = 'findings'", [project]);
|
|
37
|
-
if (findingsRow) {
|
|
38
|
-
const content = findingsRow[0][0];
|
|
39
|
-
const bullets = content.split("\n")
|
|
40
|
-
.filter(l => l.startsWith("- "))
|
|
41
|
-
.filter(l => !(/<!--\s*superseded_by:/.test(l) || /<!--\s*(?:phren:)?retract/.test(l) || /status\s+"retracted"/.test(l) || /status\s+"superseded"/.test(l)))
|
|
42
|
-
.slice(0, 10);
|
|
43
|
-
if (bullets.length > 0) {
|
|
44
|
-
parts.push("## Recent findings");
|
|
45
|
-
parts.push(bullets.join("\n"));
|
|
46
|
-
parts.push("");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const taskRow = queryRows(db, "SELECT content FROM docs WHERE project = ? AND type = 'task'", [project]);
|
|
50
|
-
if (taskRow) {
|
|
51
|
-
const content = taskRow[0][0];
|
|
52
|
-
const activeItems = content.split("\n").filter(l => l.startsWith("- "));
|
|
53
|
-
const filtered = filterTaskByPriority(activeItems);
|
|
54
|
-
const trimmed = filtered.slice(0, 5);
|
|
55
|
-
if (trimmed.length > 0) {
|
|
56
|
-
parts.push("## Active tasks");
|
|
57
|
-
parts.push(trimmed.join("\n"));
|
|
58
|
-
parts.push("");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const projectRows = queryRows(db, "SELECT DISTINCT project FROM docs ORDER BY project", []);
|
|
64
|
-
if (projectRows) {
|
|
65
|
-
parts.push("# Phren projects");
|
|
66
|
-
parts.push(projectRows.map(r => `- ${r[0]}`).join("\n"));
|
|
67
|
-
parts.push("");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
parts.push("</phren-context>");
|
|
71
|
-
if (parts.length > 2) {
|
|
72
|
-
console.log(parts.join("\n"));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// ── PostToolUse hook ─────────────────────────────────────────────────────────
|
|
76
|
-
const INTERESTING_TOOLS = new Set(["Read", "Write", "Edit", "Bash", "Glob", "Grep"]);
|
|
77
|
-
const COOLDOWN_MS = parseInt(process.env.PHREN_AUTOCAPTURE_COOLDOWN_MS ?? "30000", 10);
|
|
78
|
-
const MAX_TOOL_COMMAND_LENGTH = 200;
|
|
79
|
-
function flattenToolResponseText(value, maxChars = 4000) {
|
|
80
|
-
if (typeof value === "string")
|
|
81
|
-
return value;
|
|
82
|
-
const queue = [value];
|
|
83
|
-
const parts = [];
|
|
84
|
-
let length = 0;
|
|
85
|
-
while (queue.length > 0 && length < maxChars) {
|
|
86
|
-
const current = queue.shift();
|
|
87
|
-
if (typeof current === "string") {
|
|
88
|
-
const trimmed = current.trim();
|
|
89
|
-
if (!trimmed)
|
|
90
|
-
continue;
|
|
91
|
-
parts.push(trimmed);
|
|
92
|
-
length += trimmed.length + 1;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
if (Array.isArray(current)) {
|
|
96
|
-
queue.unshift(...current);
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (current && typeof current === "object") {
|
|
100
|
-
queue.unshift(...Object.values(current));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (parts.length > 0)
|
|
104
|
-
return parts.join("\n").slice(0, maxChars);
|
|
105
|
-
return JSON.stringify(value ?? "").slice(0, maxChars);
|
|
106
|
-
}
|
|
107
|
-
export async function handleHookTool() {
|
|
108
|
-
const ctx = buildHookContext();
|
|
109
|
-
if (!ctx.hooksEnabled) {
|
|
110
|
-
process.exit(0);
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
const start = Date.now();
|
|
114
|
-
let raw = "";
|
|
115
|
-
if (!process.stdin.isTTY) {
|
|
116
|
-
try {
|
|
117
|
-
raw = fs.readFileSync(0, "utf-8");
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
logger.debug("hookTool stdinRead", errorMessage(err));
|
|
121
|
-
process.exit(0);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
let data;
|
|
125
|
-
try {
|
|
126
|
-
data = JSON.parse(raw);
|
|
127
|
-
}
|
|
128
|
-
catch (err) {
|
|
129
|
-
logger.debug("hookTool stdinParse", errorMessage(err));
|
|
130
|
-
process.exit(0);
|
|
131
|
-
}
|
|
132
|
-
const toolName = String(data.tool_name ?? data.tool ?? "");
|
|
133
|
-
if (!INTERESTING_TOOLS.has(toolName)) {
|
|
134
|
-
process.exit(0);
|
|
135
|
-
}
|
|
136
|
-
const sessionId = data.session_id;
|
|
137
|
-
const input = (data.tool_input ?? {});
|
|
138
|
-
const entry = {
|
|
139
|
-
at: new Date().toISOString(),
|
|
140
|
-
session_id: sessionId,
|
|
141
|
-
tool: toolName,
|
|
142
|
-
};
|
|
143
|
-
if (toolName === "Read" || toolName === "Write" || toolName === "Edit") {
|
|
144
|
-
const filePath = input.file_path ?? input.path ?? undefined;
|
|
145
|
-
if (filePath)
|
|
146
|
-
entry.file = String(filePath);
|
|
147
|
-
}
|
|
148
|
-
else if (toolName === "Bash") {
|
|
149
|
-
const cmd = input.command ?? undefined;
|
|
150
|
-
if (cmd)
|
|
151
|
-
entry.command = String(cmd).slice(0, MAX_TOOL_COMMAND_LENGTH);
|
|
152
|
-
}
|
|
153
|
-
else if (toolName === "Glob") {
|
|
154
|
-
const pattern = input.pattern ?? undefined;
|
|
155
|
-
if (pattern)
|
|
156
|
-
entry.file = String(pattern);
|
|
157
|
-
}
|
|
158
|
-
else if (toolName === "Grep") {
|
|
159
|
-
const pattern = input.pattern ?? undefined;
|
|
160
|
-
const searchPath = input.path ?? undefined;
|
|
161
|
-
if (pattern)
|
|
162
|
-
entry.command = `grep ${pattern}${searchPath ? ` in ${searchPath}` : ""}`.slice(0, MAX_TOOL_COMMAND_LENGTH);
|
|
163
|
-
}
|
|
164
|
-
const responseStr = flattenToolResponseText(data.tool_response ?? "");
|
|
165
|
-
if (/(error|exception|failed|no such file|ENOENT)/i.test(responseStr)) {
|
|
166
|
-
entry.error = responseStr.slice(0, 300);
|
|
167
|
-
}
|
|
168
|
-
const cwd = (data.cwd ?? input.cwd ?? undefined);
|
|
169
|
-
let activeProject = cwd ? detectProject(ctx.phrenPath, cwd, ctx.profile) : null;
|
|
170
|
-
if (!isProjectHookEnabled(ctx.phrenPath, activeProject, "PostToolUse")) {
|
|
171
|
-
appendAuditLog(ctx.phrenPath, "hook_tool", `status=project_disabled project=${activeProject}`);
|
|
172
|
-
process.exit(0);
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
const logFile = runtimeFile(ctx.phrenPath, "tool-log.jsonl");
|
|
176
|
-
fs.mkdirSync(path.dirname(logFile), { recursive: true });
|
|
177
|
-
fs.appendFileSync(logFile, JSON.stringify(entry) + "\n");
|
|
178
|
-
}
|
|
179
|
-
catch (err) {
|
|
180
|
-
logger.debug("hookTool toolLog", errorMessage(err));
|
|
181
|
-
}
|
|
182
|
-
const cooldownFile = runtimeFile(ctx.phrenPath, "hook-tool-cooldown");
|
|
183
|
-
try {
|
|
184
|
-
if (fs.existsSync(cooldownFile)) {
|
|
185
|
-
const age = Date.now() - fs.statSync(cooldownFile).mtimeMs;
|
|
186
|
-
if (age < COOLDOWN_MS) {
|
|
187
|
-
debugLog(`hook-tool: cooldown active (${Math.round(age / 1000)}s < ${Math.round(COOLDOWN_MS / 1000)}s), skipping extraction`);
|
|
188
|
-
activeProject = null;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
logger.debug("hookTool cooldownStat", errorMessage(err));
|
|
194
|
-
}
|
|
195
|
-
if (activeProject && sessionId) {
|
|
196
|
-
try {
|
|
197
|
-
const capFile = sessionMarker(ctx.phrenPath, `tool-findings-${sessionId}`);
|
|
198
|
-
let count = 0;
|
|
199
|
-
if (fs.existsSync(capFile)) {
|
|
200
|
-
count = Number.parseInt(fs.readFileSync(capFile, "utf8").trim(), 10) || 0;
|
|
201
|
-
}
|
|
202
|
-
const sessionCap = getSessionCap();
|
|
203
|
-
if (count >= sessionCap) {
|
|
204
|
-
debugLog(`hook-tool: session cap reached (${count}/${sessionCap}), skipping extraction`);
|
|
205
|
-
activeProject = null;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
catch (err) {
|
|
209
|
-
logger.debug("hookTool sessionCapCheck", errorMessage(err));
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
const findingsLevelForTool = getProactivityLevelForFindings(ctx.phrenPath);
|
|
213
|
-
if (activeProject && findingsLevelForTool !== "low") {
|
|
214
|
-
try {
|
|
215
|
-
const candidates = filterToolFindingsForProactivity(extractToolFindings(toolName, input, responseStr, data.tool_response), findingsLevelForTool);
|
|
216
|
-
for (const { text, confidence } of candidates) {
|
|
217
|
-
appendReviewQueue(ctx.phrenPath, activeProject, "Review", [text]);
|
|
218
|
-
debugLog(`hook-tool: queued candidate for review (conf=${confidence}): ${text.slice(0, 60)}`);
|
|
219
|
-
}
|
|
220
|
-
if (candidates.length > 0) {
|
|
221
|
-
try {
|
|
222
|
-
fs.writeFileSync(cooldownFile, Date.now().toString());
|
|
223
|
-
}
|
|
224
|
-
catch (err) {
|
|
225
|
-
logger.debug("hookTool cooldownWrite", errorMessage(err));
|
|
226
|
-
}
|
|
227
|
-
if (sessionId) {
|
|
228
|
-
try {
|
|
229
|
-
const capFile = sessionMarker(ctx.phrenPath, `tool-findings-${sessionId}`);
|
|
230
|
-
let count = 0;
|
|
231
|
-
try {
|
|
232
|
-
count = Number.parseInt(fs.readFileSync(capFile, "utf8").trim(), 10) || 0;
|
|
233
|
-
}
|
|
234
|
-
catch (err) {
|
|
235
|
-
logger.debug("hookTool capFileRead", errorMessage(err));
|
|
236
|
-
}
|
|
237
|
-
count += candidates.length;
|
|
238
|
-
fs.writeFileSync(capFile, count.toString());
|
|
239
|
-
}
|
|
240
|
-
catch (err) {
|
|
241
|
-
logger.debug("hookTool capFileWrite", errorMessage(err));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
catch (err) {
|
|
247
|
-
debugLog(`hook-tool: finding extraction failed: ${errorMessage(err)}`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
else if (activeProject) {
|
|
251
|
-
debugLog("hook-tool: skipped because findings proactivity is low");
|
|
252
|
-
}
|
|
253
|
-
const elapsed = Date.now() - start;
|
|
254
|
-
debugLog(`hook-tool: ${toolName} logged in ${elapsed}ms`);
|
|
255
|
-
process.exit(0);
|
|
256
|
-
}
|
|
257
|
-
catch (err) {
|
|
258
|
-
debugLog(`hook-tool: unhandled error: ${err instanceof Error ? err.stack || err.message : String(err)}`);
|
|
259
|
-
process.exit(0);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
// Negative lookahead `(?!\(|\[)` rejects markdown link/reference patterns:
|
|
263
|
-
// [Architecture](#architecture) ← TOC anchor, content was being captured as "(#architecture)"
|
|
264
|
-
// [bug][1] ← markdown reference link, content was being captured as "[1]"
|
|
265
|
-
// produced garbage review-queue entries like "[architecture] (#architecture)".
|
|
266
|
-
const EXPLICIT_TAG_PATTERN = /\[(pitfall|decision|pattern|tradeoff|architecture|bug)\](?!\(|\[)\s*(.+)/i;
|
|
267
|
-
export function filterToolFindingsForProactivity(candidates, level = getProactivityLevelForFindings(getPhrenPath())) {
|
|
268
|
-
if (level === "high")
|
|
269
|
-
return candidates;
|
|
270
|
-
if (level === "low")
|
|
271
|
-
return [];
|
|
272
|
-
return candidates.filter((candidate) => candidate.explicit === true);
|
|
273
|
-
}
|
|
274
|
-
// Bash commands whose non-zero exit codes are routine signal, not bugs.
|
|
275
|
-
// grep/rg/ag/find returning exit 1 (no match) is the common case; conditional
|
|
276
|
-
// shell tests evaluating false is another. Don't surface these as findings.
|
|
277
|
-
const NOISY_BASH_COMMAND_PATTERNS = [
|
|
278
|
-
/^\s*(?:grep|rg|ag|ack)\b/,
|
|
279
|
-
/^\s*find\b/,
|
|
280
|
-
/^\s*which\b/,
|
|
281
|
-
/^\s*command\s+-v\b/,
|
|
282
|
-
/^\s*test\b/,
|
|
283
|
-
/^\s*\[\s/,
|
|
284
|
-
/^\s*\[\[\s/,
|
|
285
|
-
/^\s*pgrep\b/,
|
|
286
|
-
/^\s*pkill\b/,
|
|
287
|
-
/^\s*git\s+diff\s+--quiet/,
|
|
288
|
-
];
|
|
289
|
-
function isNoisyBashCommand(cmd) {
|
|
290
|
-
if (/\|\|\s*true\b/.test(cmd))
|
|
291
|
-
return true;
|
|
292
|
-
if (/2>\s*\/dev\/null/.test(cmd))
|
|
293
|
-
return true;
|
|
294
|
-
return NOISY_BASH_COMMAND_PATTERNS.some((re) => re.test(cmd));
|
|
295
|
-
}
|
|
296
|
-
function extractToolErrorSignal(toolResponse) {
|
|
297
|
-
if (!toolResponse || typeof toolResponse !== "object") {
|
|
298
|
-
return { isError: false, hasExitCode: false };
|
|
299
|
-
}
|
|
300
|
-
const tr = toolResponse;
|
|
301
|
-
const isError = Boolean(tr.is_error ?? tr.isError);
|
|
302
|
-
const rawExit = tr.exit_code ?? tr.exitCode;
|
|
303
|
-
const exitCode = typeof rawExit === "number" ? rawExit : undefined;
|
|
304
|
-
return { isError, exitCode, hasExitCode: exitCode !== undefined };
|
|
305
|
-
}
|
|
306
|
-
export function extractToolFindings(toolName, input, responseStr, toolResponse) {
|
|
307
|
-
const candidates = [];
|
|
308
|
-
const changedContent = (toolName === "Edit" || toolName === "Write")
|
|
309
|
-
? String(input.new_string ?? input.content ?? "")
|
|
310
|
-
: "";
|
|
311
|
-
const explicitSource = changedContent || responseStr;
|
|
312
|
-
const tagMatches = explicitSource.matchAll(new RegExp(EXPLICIT_TAG_PATTERN.source, "gi"));
|
|
313
|
-
for (const m of tagMatches) {
|
|
314
|
-
const tag = m[1].toLowerCase();
|
|
315
|
-
const content = m[2].replace(/\s+/g, " ").trim().slice(0, 200);
|
|
316
|
-
if (content) {
|
|
317
|
-
candidates.push({ text: `[${tag}] ${content}`, confidence: 0.85, explicit: true });
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (toolName === "Edit" || toolName === "Write") {
|
|
321
|
-
const filePath = String(input.file_path ?? input.path ?? "unknown");
|
|
322
|
-
const filename = path.basename(filePath);
|
|
323
|
-
if (/\b(TODO|FIXME)\b/.test(changedContent)) {
|
|
324
|
-
const firstLine = changedContent.split("\n").find((l) => /\b(TODO|FIXME)\b/.test(l));
|
|
325
|
-
if (firstLine) {
|
|
326
|
-
candidates.push({
|
|
327
|
-
text: `[pitfall] ${filename}: ${firstLine.trim().slice(0, 150)}`,
|
|
328
|
-
confidence: 0.45,
|
|
329
|
-
explicit: false,
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
// (Removed: try/catch additions used to emit "[pitfall] ... error handling added near ..."
|
|
334
|
-
// candidates. Adding error handling is normal code, not a pitfall — the heuristic produced
|
|
335
|
-
// ~21 false positives for every real one in observed stores. If we ever need this back,
|
|
336
|
-
// gate on a *removed* try/catch, not an added one.)
|
|
337
|
-
}
|
|
338
|
-
if (toolName === "Bash") {
|
|
339
|
-
const fullCmd = String(input.command ?? "");
|
|
340
|
-
const cmdShort = fullCmd.slice(0, 30);
|
|
341
|
-
const errorSignal = extractToolErrorSignal(toolResponse);
|
|
342
|
-
// Only emit a [bug] candidate when (a) we have a definite error signal from the tool
|
|
343
|
-
// result (is_error or non-zero exit_code) and (b) the command isn't a known-noisy one
|
|
344
|
-
// like grep/find/test where exit 1 just means "didn't match" rather than a failure.
|
|
345
|
-
const hasDefiniteError = errorSignal.isError || (errorSignal.hasExitCode && (errorSignal.exitCode ?? 0) !== 0);
|
|
346
|
-
if (hasDefiniteError && cmdShort && !isNoisyBashCommand(fullCmd)) {
|
|
347
|
-
const firstErrorLine = responseStr.split("\n").find((l) => /(error|exception|failed|ENOENT|command not found|permission denied)/i.test(l));
|
|
348
|
-
const detail = (firstErrorLine ?? responseStr.split("\n")[0] ?? "").trim().slice(0, 150);
|
|
349
|
-
if (detail) {
|
|
350
|
-
candidates.push({
|
|
351
|
-
text: `[bug] command '${cmdShort}' failed: ${detail}`,
|
|
352
|
-
confidence: 0.55,
|
|
353
|
-
explicit: false,
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return candidates;
|
|
359
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
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>;
|