@phren/cli 0.1.29 → 0.1.31
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/cli/config.d.ts +1 -0
- package/dist/cli/config.js +162 -68
- package/dist/config/resolve.d.ts +56 -0
- package/dist/config/resolve.js +241 -0
- package/dist/config/schema.d.ts +79 -0
- package/dist/config/schema.js +498 -0
- package/dist/governance/policy.d.ts +6 -0
- package/dist/governance/policy.js +6 -3
- package/dist/index.js +21 -1
- package/dist/tools/config.js +25 -0
- package/dist/ui/page.js +6 -0
- package/dist/ui/scripts.js +35 -0
- package/dist/ui/server.js +43 -3
- package/package.json +1 -1
package/dist/ui/scripts.js
CHANGED
|
@@ -1195,6 +1195,30 @@ export function renderTasksAndSettingsScript(authToken) {
|
|
|
1195
1195
|
workflowEl.innerHTML = wfHtml;
|
|
1196
1196
|
}
|
|
1197
1197
|
|
|
1198
|
+
var indexEl = document.getElementById('settings-index');
|
|
1199
|
+
if (indexEl && !isProject) {
|
|
1200
|
+
var idx = data.indexPolicy || {};
|
|
1201
|
+
var idxHtml = '';
|
|
1202
|
+
function idxGlobRow(label, field, note) {
|
|
1203
|
+
var val = Array.isArray(idx[field]) ? idx[field].join(', ') : '';
|
|
1204
|
+
idxHtml += '<div class="settings-control">';
|
|
1205
|
+
idxHtml += '<div class="settings-control-header"><span class="settings-control-label">' + esc(label) + '</span></div>';
|
|
1206
|
+
idxHtml += '<div class="settings-control-note">' + esc(note) + '</div>';
|
|
1207
|
+
idxHtml += '<div style="display:flex;gap:8px;align-items:center;margin-top:8px">' +
|
|
1208
|
+
'<input type="text" id="idx-input-' + esc(field) + '" value="' + esc(val) + '" style="flex:1;min-width:0;border:1px solid var(--border);border-radius:var(--radius-sm);padding:4px 8px;font-size:var(--text-sm);background:var(--surface);color:var(--ink)">' +
|
|
1209
|
+
'<button data-ts-action="setGlobalIndex" data-field="' + esc(field) + '" class="settings-chip active" style="font-size:11px">Set</button>' +
|
|
1210
|
+
'</div></div>';
|
|
1211
|
+
}
|
|
1212
|
+
idxGlobRow('Include globs', 'includeGlobs', 'Comma-separated glob patterns the indexer reads.');
|
|
1213
|
+
idxGlobRow('Exclude globs', 'excludeGlobs', 'Comma-separated glob patterns the indexer skips. Excludes win over includes.');
|
|
1214
|
+
idxHtml += '<div class="settings-control"><div class="settings-control-header"><span class="settings-control-label">Index hidden files</span>';
|
|
1215
|
+
idxHtml += '<button data-ts-action="toggleIndexHidden" data-enabled="' + (idx.includeHidden ? 'true' : 'false') + '" class="settings-chip' + (idx.includeHidden ? ' active' : '') + '" style="margin-left:auto">' + (idx.includeHidden ? 'On' : 'Off') + '</button></div>';
|
|
1216
|
+
idxHtml += '<div class="settings-control-note">When on, dotfiles and dot-directories are eligible for indexing.</div></div>';
|
|
1217
|
+
indexEl.innerHTML = idxHtml;
|
|
1218
|
+
} else if (indexEl && isProject) {
|
|
1219
|
+
indexEl.innerHTML = '<div style="color:var(--muted);font-size:var(--text-sm)">Index policy is global — switch to Global scope to edit it.</div>';
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1198
1222
|
var integrationsEl = document.getElementById('settings-integrations');
|
|
1199
1223
|
if (integrationsEl && !isProject) {
|
|
1200
1224
|
var tools = Array.isArray(data.hookTools) ? data.hookTools : [];
|
|
@@ -1383,6 +1407,17 @@ export function renderTasksAndSettingsScript(authToken) {
|
|
|
1383
1407
|
var val = inputEl ? inputEl.value : '';
|
|
1384
1408
|
postProjectOverride(proj, field, val, false);
|
|
1385
1409
|
}
|
|
1410
|
+
else if (action === 'setGlobalIndex') {
|
|
1411
|
+
var field = actionEl.getAttribute('data-field') || '';
|
|
1412
|
+
var inputEl = document.getElementById('idx-input-' + field);
|
|
1413
|
+
var payload = {};
|
|
1414
|
+
payload[field] = inputEl ? inputEl.value : '';
|
|
1415
|
+
postSettings('/api/settings/index-policy', payload, 'Index policy updated.');
|
|
1416
|
+
}
|
|
1417
|
+
else if (action === 'toggleIndexHidden') {
|
|
1418
|
+
var nextHidden = actionEl.getAttribute('data-enabled') !== 'true';
|
|
1419
|
+
postSettings('/api/settings/index-policy', { includeHidden: String(nextHidden) }, 'Index policy updated.');
|
|
1420
|
+
}
|
|
1386
1421
|
});
|
|
1387
1422
|
|
|
1388
1423
|
// Keydown delegation for add-task inputs (Enter key)
|
package/dist/ui/server.js
CHANGED
|
@@ -13,8 +13,10 @@ import { readInstallPreferences, writeInstallPreferences, writeGovernanceInstall
|
|
|
13
13
|
import { buildGraph, collectProjectsForUI, collectSkillsForUI, getHooksData, isAllowedSkillPath, readSyncSnapshot, recentAccepted, recentUsage, } from "./data.js";
|
|
14
14
|
import { CONSOLIDATION_ENTRY_THRESHOLD } from "../content/validate.js";
|
|
15
15
|
import { ensureTopicReferenceDoc, getProjectTopicsResponse, listProjectReferenceDocs, pinProjectTopicSuggestion, readReferenceContent, reclassifyLegacyTopicDocs, unpinProjectTopicSuggestion, writeProjectTopics, } from "../project-topics.js";
|
|
16
|
-
import { getWorkflowPolicy, updateWorkflowPolicy, mergeConfig, getRetentionPolicy, getProjectConfigOverrides, VALID_TASK_MODES } from "../governance/policy.js";
|
|
16
|
+
import { getWorkflowPolicy, updateWorkflowPolicy, mergeConfig, getRetentionPolicy, getProjectConfigOverrides, getIndexPolicy, updateIndexPolicy, VALID_TASK_MODES } from "../governance/policy.js";
|
|
17
17
|
import { readProjectConfig, updateProjectConfigOverrides } from "../project-config.js";
|
|
18
|
+
import { buildConfigView } from "../config/resolve.js";
|
|
19
|
+
import { CONFIG_DOMAINS } from "../config/schema.js";
|
|
18
20
|
import { findSkill } from "../skill/registry.js";
|
|
19
21
|
import { setSkillEnabledAndSync } from "../skill/files.js";
|
|
20
22
|
import { repairPreexistingInstall } from "../init/setup.js";
|
|
@@ -527,13 +529,15 @@ function handleGetSettings(res, url, ctx) {
|
|
|
527
529
|
hasClaudeMd: fs.existsSync(path.join(projectDir, "CLAUDE.md")), findingCount, taskCount,
|
|
528
530
|
};
|
|
529
531
|
}
|
|
532
|
+
const indexPolicy = getIndexPolicy(ctx.phrenPath);
|
|
533
|
+
const view = buildConfigView(ctx.phrenPath, settingsProject && isValidProjectName(settingsProject) ? settingsProject : undefined);
|
|
530
534
|
jsonOk(res, {
|
|
531
535
|
ok: true, proactivity: prefs.proactivity || "high", proactivityFindings,
|
|
532
536
|
proactivityTask: prefs.proactivityTask || prefs.proactivity || "high", taskMode: workflowPolicy.taskMode,
|
|
533
537
|
findingSensitivity: workflowPolicy.findingSensitivity || "balanced", autoCaptureEnabled: proactivityFindings !== "low",
|
|
534
538
|
consolidationEntryThreshold: CONSOLIDATION_ENTRY_THRESHOLD, hooksEnabled: hooksData.globalEnabled,
|
|
535
539
|
mcpEnabled: prefs.mcpEnabled !== false, hookTools: hooksData.tools,
|
|
536
|
-
retentionPolicy, workflowPolicy, merged, overrides, projectInfo,
|
|
540
|
+
retentionPolicy, workflowPolicy, indexPolicy, merged, overrides, projectInfo, view,
|
|
537
541
|
});
|
|
538
542
|
}
|
|
539
543
|
catch (err) {
|
|
@@ -547,7 +551,24 @@ function handleGetConfig(res, url, ctx) {
|
|
|
547
551
|
try {
|
|
548
552
|
const config = mergeConfig(ctx.phrenPath, project || undefined);
|
|
549
553
|
const projects = getProjectDirs(ctx.phrenPath, ctx.profile).map((d) => path.basename(d)).filter((p) => p !== "global");
|
|
550
|
-
|
|
554
|
+
const view = buildConfigView(ctx.phrenPath, project || undefined);
|
|
555
|
+
jsonOk(res, { ok: true, config, projects, view });
|
|
556
|
+
}
|
|
557
|
+
catch (err) {
|
|
558
|
+
jsonErr(res, errorMessage(err));
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Resolved config view plus the shared schema — everything the settings UI
|
|
563
|
+
* needs to render every domain with a consistent source chip, in one call.
|
|
564
|
+
*/
|
|
565
|
+
function handleGetConfigView(res, url, ctx) {
|
|
566
|
+
const project = String(parseQs(url).project || "");
|
|
567
|
+
if (project && !isValidProjectName(project))
|
|
568
|
+
return jsonErr(res, "Invalid project name", 400);
|
|
569
|
+
try {
|
|
570
|
+
const view = buildConfigView(ctx.phrenPath, project || undefined);
|
|
571
|
+
jsonOk(res, { ok: true, view, schema: CONFIG_DOMAINS });
|
|
551
572
|
}
|
|
552
573
|
catch (err) {
|
|
553
574
|
jsonErr(res, errorMessage(err));
|
|
@@ -831,6 +852,23 @@ function handlePostSettingsAutoCapture(req, res, url, ctx) {
|
|
|
831
852
|
jsonOk(res, { ok: true, autoCaptureEnabled: enabled, proactivityFindings: next });
|
|
832
853
|
});
|
|
833
854
|
}
|
|
855
|
+
function handlePostSettingsIndexPolicy(req, res, url, ctx) {
|
|
856
|
+
withPostBody(req, res, url, ctx, (parsed) => {
|
|
857
|
+
const patch = {};
|
|
858
|
+
const toGlobList = (v) => (Array.isArray(v) ? v : String(v ?? "").split(","))
|
|
859
|
+
.map((s) => String(s).trim())
|
|
860
|
+
.filter(Boolean);
|
|
861
|
+
if (Object.prototype.hasOwnProperty.call(parsed, "includeGlobs"))
|
|
862
|
+
patch.includeGlobs = toGlobList(parsed.includeGlobs);
|
|
863
|
+
if (Object.prototype.hasOwnProperty.call(parsed, "excludeGlobs"))
|
|
864
|
+
patch.excludeGlobs = toGlobList(parsed.excludeGlobs);
|
|
865
|
+
if (Object.prototype.hasOwnProperty.call(parsed, "includeHidden")) {
|
|
866
|
+
patch.includeHidden = String(parsed.includeHidden).toLowerCase() === "true";
|
|
867
|
+
}
|
|
868
|
+
const result = updateIndexPolicy(ctx.phrenPath, patch);
|
|
869
|
+
jsonOk(res, result.ok ? { ok: true, indexPolicy: result.data } : { ok: false, error: result.error });
|
|
870
|
+
});
|
|
871
|
+
}
|
|
834
872
|
function handlePostSettingsMcpEnabled(req, res, url, ctx) {
|
|
835
873
|
withPostBody(req, res, url, ctx, (parsed) => {
|
|
836
874
|
const enabled = String(parsed.enabled || "").toLowerCase() === "true";
|
|
@@ -1081,6 +1119,7 @@ export function createWebUiHttpServer(phrenPath, renderPage, profile, opts) {
|
|
|
1081
1119
|
case "/api/tasks": return handleGetTasks(res, ctx);
|
|
1082
1120
|
case "/api/settings": return handleGetSettings(res, url, ctx);
|
|
1083
1121
|
case "/api/config": return handleGetConfig(res, url, ctx);
|
|
1122
|
+
case "/api/config/view": return handleGetConfigView(res, url, ctx);
|
|
1084
1123
|
case "/api/csrf-token": return handleGetCsrfToken(res, ctx);
|
|
1085
1124
|
case "/api/profiles": return handleGetProfiles(res, ctx);
|
|
1086
1125
|
case "/api/search": return await handleGetSearch(res, url, ctx);
|
|
@@ -1121,6 +1160,7 @@ export function createWebUiHttpServer(phrenPath, renderPage, profile, opts) {
|
|
|
1121
1160
|
case "/api/settings/proactivity": return handlePostSettingsProactivity(req, res, url, ctx);
|
|
1122
1161
|
case "/api/settings/auto-capture": return handlePostSettingsAutoCapture(req, res, url, ctx);
|
|
1123
1162
|
case "/api/settings/mcp-enabled": return handlePostSettingsMcpEnabled(req, res, url, ctx);
|
|
1163
|
+
case "/api/settings/index-policy": return handlePostSettingsIndexPolicy(req, res, url, ctx);
|
|
1124
1164
|
case "/api/settings/project-overrides": return handlePostSettingsProjectOverrides(req, res, url, ctx);
|
|
1125
1165
|
}
|
|
1126
1166
|
// Prefix-matched write routes
|