@phren/cli 0.1.30 → 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/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/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
|