@phren/cli 0.3.71 → 0.3.72
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/bridge/browser-env.d.ts +5 -0
- package/dist/bridge/browser-env.js +86 -0
- package/dist/bridge/browser-protocol.d.ts +120 -0
- package/dist/bridge/browser-protocol.js +70 -0
- package/dist/bridge/browser-recordings.d.ts +63 -0
- package/dist/bridge/browser-recordings.js +148 -0
- package/dist/bridge/browser-registry.d.ts +64 -0
- package/dist/bridge/browser-registry.js +262 -0
- package/dist/bridge/browser-routes.d.ts +4 -0
- package/dist/bridge/browser-routes.js +39 -0
- package/dist/bridge/browser-shim/phren-playwright.cjs +184 -0
- package/dist/bridge/browser-socket.d.ts +2 -0
- package/dist/bridge/browser-socket.js +10 -0
- package/dist/bridge/browser-stream.d.ts +3 -0
- package/dist/bridge/browser-stream.js +129 -0
- package/dist/bridge/dispatch.d.ts +10 -0
- package/dist/bridge/dispatch.js +3 -1
- package/dist/bridge/dream-schedule.d.ts +133 -0
- package/dist/bridge/dream-schedule.js +322 -0
- package/dist/bridge/herdr.js +15 -6
- package/dist/bridge/install.js +4 -0
- package/dist/bridge/launch-brief.d.ts +11 -0
- package/dist/bridge/launch-brief.js +22 -0
- package/dist/bridge/pane-status.js +1 -1
- package/dist/bridge/server-routes.d.ts +3 -0
- package/dist/bridge/server-routes.js +15 -15
- package/dist/bridge/server-stream.d.ts +4 -0
- package/dist/bridge/server-stream.js +24 -5
- package/dist/bridge/server.js +23 -3
- package/dist/bridge/session-move.d.ts +10 -4
- package/dist/bridge/session-move.js +65 -34
- package/dist/bridge/simulator-stream.d.ts +2 -0
- package/dist/bridge/simulator-stream.js +2 -0
- package/dist/bridge/tab-activity.d.ts +2 -0
- package/dist/bridge/tab-activity.js +15 -2
- package/dist/bridge/task-routes.d.ts +20 -16
- package/dist/bridge/task-routes.js +1 -1
- package/dist/bridge/terminal-herdr.js +2 -1
- package/dist/bridge/terminal-tmux.js +2 -1
- package/dist/bridge/worker-reports.js +15 -3
- package/dist/bridge-hook.mjs +36800 -35213
- package/dist/capabilities/mcp.js +1 -1
- package/dist/cli/config-dreaming.d.ts +7 -0
- package/dist/cli/config-dreaming.js +72 -0
- package/dist/cli/config.js +6 -0
- package/dist/cli/dream.d.ts +59 -0
- package/dist/cli/dream.js +315 -0
- package/dist/cli/namespaces-tasks.js +14 -0
- package/dist/cli-registry.js +24 -1
- package/dist/config/dreaming.d.ts +82 -0
- package/dist/config/dreaming.js +195 -0
- package/dist/config/resolve.js +11 -0
- package/dist/config/schema.d.ts +4 -4
- package/dist/config/schema.js +157 -1
- package/dist/content/citation-freshness.js +6 -0
- package/dist/content/learning.d.ts +1 -0
- package/dist/content/learning.js +2 -0
- package/dist/data/access.d.ts +1 -1
- package/dist/data/access.js +3 -1
- package/dist/data/task-contract.d.ts +5 -4
- package/dist/data/tasks.d.ts +5 -0
- package/dist/data/tasks.js +28 -2
- package/dist/dream/apply.d.ts +69 -0
- package/dist/dream/apply.js +372 -0
- package/dist/dream/budget.d.ts +78 -0
- package/dist/dream/budget.js +180 -0
- package/dist/dream/collect.d.ts +86 -0
- package/dist/dream/collect.js +449 -0
- package/dist/dream/eval/dream-adapter.d.ts +16 -0
- package/dist/dream/eval/dream-adapter.js +21 -0
- package/dist/dream/eval/fixture.d.ts +53 -0
- package/dist/dream/eval/fixture.js +172 -0
- package/dist/dream/eval/index.d.ts +40 -0
- package/dist/dream/eval/index.js +78 -0
- package/dist/dream/eval/score.d.ts +34 -0
- package/dist/dream/eval/score.js +99 -0
- package/dist/dream/eval/scripted-model.d.ts +19 -0
- package/dist/dream/eval/scripted-model.js +70 -0
- package/dist/dream/pages.d.ts +68 -0
- package/dist/dream/pages.js +220 -0
- package/dist/dream/privacy.d.ts +3 -0
- package/dist/dream/privacy.js +18 -0
- package/dist/dream/prompt.d.ts +13 -0
- package/dist/dream/prompt.js +84 -0
- package/dist/dream/run.d.ts +98 -0
- package/dist/dream/run.js +317 -0
- package/dist/dream/types.d.ts +74 -0
- package/dist/dream/types.js +4 -0
- package/dist/finding/lifecycle.d.ts +2 -2
- package/dist/finding/lifecycle.js +5 -2
- package/dist/finding/versions.d.ts +4 -0
- package/dist/finding/versions.js +28 -0
- package/dist/index.js +1 -0
- package/dist/modules/registry.js +9 -7
- package/dist/project-config.d.ts +3 -0
- package/dist/task/merge-links.d.ts +38 -0
- package/dist/task/merge-links.js +45 -0
- package/dist/task/reconcile.d.ts +39 -0
- package/dist/task/reconcile.js +201 -0
- package/dist/task/report-links.d.ts +10 -0
- package/dist/task/report-links.js +47 -0
- package/dist/tools/config.js +46 -4
- package/dist/tools/dispatch.js +2 -1
- package/dist/tools/dream.d.ts +3 -0
- package/dist/tools/dream.js +123 -0
- package/dist/tools/tasks.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// dream(): one dreaming pass for one project. Collect what happened, ask the helper model
|
|
2
|
+
// for a changeset, keep only the changes that are well-formed, allowed and evidenced, then
|
|
3
|
+
// apply or propose them and record the run. One dream per project at a time.
|
|
4
|
+
import * as crypto from "crypto";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
import { redactSecretsForLog } from "../content/secrets.js";
|
|
7
|
+
import { sanitizeDream } from "./privacy.js";
|
|
8
|
+
import { helperFor, runHelper } from "../bridge/helper.js";
|
|
9
|
+
import { buildConfigView } from "../config/resolve.js";
|
|
10
|
+
import { scanForSecrets } from "../content/secrets.js";
|
|
11
|
+
import { tryFileLock } from "../governance/locks.js";
|
|
12
|
+
import { findPhrenPath, runtimeDir } from "../phren-paths.js";
|
|
13
|
+
import { isValidProjectName } from "../utils-paths.js";
|
|
14
|
+
import { applyChangeset, countOutcomes, findingVersions, PAGE_PATH, readLastRun, recordDream, writeLastRun } from "./apply.js";
|
|
15
|
+
import { collect, projectStoreDir } from "./collect.js";
|
|
16
|
+
import { buildDreamPrompt, DREAM_PHASES, PHASE_OPS } from "./prompt.js";
|
|
17
|
+
export const DREAM_CONFIG_DEFAULTS = {
|
|
18
|
+
enabled: false,
|
|
19
|
+
mode: "propose",
|
|
20
|
+
cadence: "nightly",
|
|
21
|
+
window: "02:00-05:00",
|
|
22
|
+
idleMinutes: 45,
|
|
23
|
+
lookbackHours: 24,
|
|
24
|
+
maxChanges: 25,
|
|
25
|
+
injectBudgetKB: 8,
|
|
26
|
+
phases: [...DREAM_PHASES],
|
|
27
|
+
model: "",
|
|
28
|
+
};
|
|
29
|
+
const positive = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
30
|
+
/** Coerce raw values (from the `dreaming` config domain or a caller) onto the defaults; anything malformed falls back. */
|
|
31
|
+
export function normalizeDreamConfig(raw) {
|
|
32
|
+
const d = DREAM_CONFIG_DEFAULTS;
|
|
33
|
+
const phases = Array.isArray(raw.phases)
|
|
34
|
+
? raw.phases.filter((p) => typeof p === "string" && DREAM_PHASES.includes(p))
|
|
35
|
+
: d.phases;
|
|
36
|
+
return {
|
|
37
|
+
enabled: typeof raw.enabled === "boolean" ? raw.enabled : d.enabled,
|
|
38
|
+
mode: raw.mode === "apply" || raw.mode === "propose" ? raw.mode : d.mode,
|
|
39
|
+
cadence: ["nightly", "idle", "weekly", "manual"].includes(String(raw.cadence)) ? raw.cadence : d.cadence,
|
|
40
|
+
window: typeof raw.window === "string" && /^\d{2}:\d{2}-\d{2}:\d{2}$/.test(raw.window) ? raw.window : d.window,
|
|
41
|
+
idleMinutes: positive(raw.idleMinutes, d.idleMinutes),
|
|
42
|
+
lookbackHours: positive(raw.lookbackHours, d.lookbackHours),
|
|
43
|
+
maxChanges: Math.floor(positive(raw.maxChanges, d.maxChanges)),
|
|
44
|
+
injectBudgetKB: positive(raw.injectBudgetKB, d.injectBudgetKB),
|
|
45
|
+
phases: Array.isArray(raw.phases) ? phases : d.phases,
|
|
46
|
+
model: typeof raw.model === "string" ? raw.model.trim() : d.model,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** The project's resolved `dreaming.*` settings (defaults → global → project), via the shared config resolver. */
|
|
50
|
+
export function readDreamConfig(phrenPath, project) {
|
|
51
|
+
const raw = {};
|
|
52
|
+
try {
|
|
53
|
+
const fields = buildConfigView(phrenPath, project).fields;
|
|
54
|
+
for (const key of Object.keys(DREAM_CONFIG_DEFAULTS)) {
|
|
55
|
+
const field = fields[`dreaming.${key}`];
|
|
56
|
+
if (field && field.value !== undefined)
|
|
57
|
+
raw[key] = field.value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch { /* An unreadable config means defaults, which means off. */ }
|
|
61
|
+
return normalizeDreamConfig(raw);
|
|
62
|
+
}
|
|
63
|
+
// ── Parse and validate ───────────────────────────────────────────────────────
|
|
64
|
+
/** The JSON object in a model reply, tolerating a code fence or stray prose around it. */
|
|
65
|
+
export function parseChangesetJson(output) {
|
|
66
|
+
const text = output.trim().replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/, "");
|
|
67
|
+
const start = text.indexOf("{"), end = text.lastIndexOf("}");
|
|
68
|
+
if (start < 0 || end <= start)
|
|
69
|
+
return { ok: false, error: "The model's reply has no JSON object." };
|
|
70
|
+
let parsed;
|
|
71
|
+
try {
|
|
72
|
+
parsed = JSON.parse(text.slice(start, end + 1));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return { ok: false, error: "The model's reply is not valid JSON." };
|
|
76
|
+
}
|
|
77
|
+
const value = parsed;
|
|
78
|
+
if (!value || typeof value !== "object" || !Array.isArray(value.changes))
|
|
79
|
+
return { ok: false, error: "The model's JSON has no changes array." };
|
|
80
|
+
return { ok: true, value: { changes: value.changes, notes: typeof value.notes === "string" ? value.notes : "" } };
|
|
81
|
+
}
|
|
82
|
+
const KNOWN_OPS = ["add_finding", "supersede", "retract", "edit", "merge", "move_topic", "promote_truth", "demote_truth", "write_page", "link"];
|
|
83
|
+
const NO_EVIDENCE_OPS = ["move_topic", "demote_truth", "link", "write_page"];
|
|
84
|
+
const FINDING_TYPES = ["decision", "pitfall", "pattern", "bug"];
|
|
85
|
+
const EVIDENCE_KINDS = ["transcript", "code", "git", "finding"];
|
|
86
|
+
const TEXT_MAX = 5_000;
|
|
87
|
+
const PAGE_MAX = 64 * 1024;
|
|
88
|
+
const str = (value, max = TEXT_MAX) => typeof value === "string" && value.trim() && value.length <= max ? value.trim() : undefined;
|
|
89
|
+
function evidenceList(value) {
|
|
90
|
+
if (!Array.isArray(value))
|
|
91
|
+
return [];
|
|
92
|
+
const list = [];
|
|
93
|
+
for (const raw of value) {
|
|
94
|
+
const e = raw;
|
|
95
|
+
if (!e || typeof e !== "object" || !EVIDENCE_KINDS.includes(String(e.kind)))
|
|
96
|
+
continue;
|
|
97
|
+
const ref = str(e.ref, 300);
|
|
98
|
+
if (!ref)
|
|
99
|
+
continue;
|
|
100
|
+
const quote = str(e.quote, 1_000);
|
|
101
|
+
list.push({ kind: e.kind, ref, ...(quote ? { quote } : {}) });
|
|
102
|
+
}
|
|
103
|
+
return list;
|
|
104
|
+
}
|
|
105
|
+
/** One raw change as a typed change, or why it can't be one. */
|
|
106
|
+
function shapeChange(raw, ctx) {
|
|
107
|
+
const op = raw.op;
|
|
108
|
+
const evidence = evidenceList(raw.evidence);
|
|
109
|
+
const fid = (value) => {
|
|
110
|
+
const id = str(value, 20)?.replace(/^fid:/, "");
|
|
111
|
+
return id && ctx.fids.has(id) ? id : undefined;
|
|
112
|
+
};
|
|
113
|
+
const needFid = () => `unknown findingId ${JSON.stringify(raw.findingId)}`;
|
|
114
|
+
switch (op) {
|
|
115
|
+
case "add_finding": {
|
|
116
|
+
const text = str(raw.text);
|
|
117
|
+
if (!text)
|
|
118
|
+
return "missing text";
|
|
119
|
+
const findingType = FINDING_TYPES.includes(String(raw.findingType)) ? raw.findingType : undefined;
|
|
120
|
+
const topic = str(raw.topic, 64);
|
|
121
|
+
return { op, text, ...(findingType ? { findingType } : {}), ...(topic ? { topic } : {}), evidence };
|
|
122
|
+
}
|
|
123
|
+
case "supersede":
|
|
124
|
+
case "edit": {
|
|
125
|
+
const findingId = fid(raw.findingId), newText = str(raw.newText);
|
|
126
|
+
if (!findingId)
|
|
127
|
+
return needFid();
|
|
128
|
+
if (!newText)
|
|
129
|
+
return "missing newText";
|
|
130
|
+
return { op, findingId, newText, evidence };
|
|
131
|
+
}
|
|
132
|
+
case "retract": {
|
|
133
|
+
const findingId = fid(raw.findingId), reason = str(raw.reason, 500);
|
|
134
|
+
if (!findingId)
|
|
135
|
+
return needFid();
|
|
136
|
+
if (!reason)
|
|
137
|
+
return "missing reason";
|
|
138
|
+
return { op, findingId, reason, evidence };
|
|
139
|
+
}
|
|
140
|
+
case "merge": {
|
|
141
|
+
const ids = Array.isArray(raw.findingIds) ? raw.findingIds.map(fid) : [];
|
|
142
|
+
const newText = str(raw.newText);
|
|
143
|
+
if (ids.length < 2 || ids.some(id => !id))
|
|
144
|
+
return `merge needs two or more known findingIds, got ${JSON.stringify(raw.findingIds)}`;
|
|
145
|
+
if (new Set(ids).size !== ids.length)
|
|
146
|
+
return "merge lists a finding twice";
|
|
147
|
+
if (!newText)
|
|
148
|
+
return "missing newText";
|
|
149
|
+
return { op, findingIds: ids, newText, evidence };
|
|
150
|
+
}
|
|
151
|
+
case "move_topic": {
|
|
152
|
+
const findingId = fid(raw.findingId), topic = str(raw.topic, 64);
|
|
153
|
+
if (!findingId)
|
|
154
|
+
return needFid();
|
|
155
|
+
if (!topic || !ctx.topics.has(topic))
|
|
156
|
+
return `unknown topic ${JSON.stringify(raw.topic)}`;
|
|
157
|
+
return { op, findingId, topic };
|
|
158
|
+
}
|
|
159
|
+
case "promote_truth": {
|
|
160
|
+
const findingId = fid(raw.findingId), text = str(raw.text, 500);
|
|
161
|
+
if (!findingId)
|
|
162
|
+
return needFid();
|
|
163
|
+
if (!text)
|
|
164
|
+
return "missing text";
|
|
165
|
+
return { op, findingId, text, evidence };
|
|
166
|
+
}
|
|
167
|
+
case "demote_truth": {
|
|
168
|
+
const truth = str(raw.truth, 2_000), reason = str(raw.reason, 500);
|
|
169
|
+
if (!truth || !ctx.truths.includes(truth.replace(/^- /, "")))
|
|
170
|
+
return `unknown truth ${JSON.stringify(raw.truth)}`;
|
|
171
|
+
if (!reason)
|
|
172
|
+
return "missing reason";
|
|
173
|
+
return { op, truth: truth.replace(/^- /, ""), reason };
|
|
174
|
+
}
|
|
175
|
+
case "write_page": {
|
|
176
|
+
const page = str(raw.page, 120), markdown = str(raw.markdown, PAGE_MAX);
|
|
177
|
+
if (!page || !PAGE_PATH.test(page))
|
|
178
|
+
return `bad page path ${JSON.stringify(raw.page)}`;
|
|
179
|
+
if (!markdown)
|
|
180
|
+
return "missing markdown";
|
|
181
|
+
const links = Array.isArray(raw.links) ? raw.links.filter((l) => typeof l === "string" && /^[a-z0-9][a-z0-9-]{0,63}$/.test(l)) : [];
|
|
182
|
+
return { op, page, markdown, links };
|
|
183
|
+
}
|
|
184
|
+
case "link": {
|
|
185
|
+
const findingId = fid(raw.findingId), entity = str(raw.entity, 100);
|
|
186
|
+
if (!findingId)
|
|
187
|
+
return needFid();
|
|
188
|
+
if (!entity)
|
|
189
|
+
return "missing entity";
|
|
190
|
+
return { op, findingId, entity };
|
|
191
|
+
}
|
|
192
|
+
default:
|
|
193
|
+
return `unknown op ${JSON.stringify(raw.op)}`;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/** Keep the well-formed, allowed, evidenced changes up to maxChanges; say why each other one was dropped. */
|
|
197
|
+
export function validateChanges(rawChanges, ctx) {
|
|
198
|
+
const allowed = new Set(ctx.phases.flatMap(phase => PHASE_OPS[phase]));
|
|
199
|
+
const changes = [];
|
|
200
|
+
const dropped = [];
|
|
201
|
+
rawChanges.forEach((value, index) => {
|
|
202
|
+
const raw = (value && typeof value === "object" ? value : {});
|
|
203
|
+
const op = typeof raw.op === "string" ? raw.op : String(raw.op);
|
|
204
|
+
const drop = (reason) => dropped.push(sanitizeDream({ index, op, reason }));
|
|
205
|
+
if (!KNOWN_OPS.includes(op))
|
|
206
|
+
return drop("unknown op");
|
|
207
|
+
if (!allowed.has(op))
|
|
208
|
+
return drop("op not allowed by the enabled phases");
|
|
209
|
+
const shaped = shapeChange(raw, ctx);
|
|
210
|
+
if (typeof shaped === "string")
|
|
211
|
+
return drop(shaped);
|
|
212
|
+
if (!NO_EVIDENCE_OPS.includes(shaped.op) && !("evidence" in shaped && shaped.evidence.length))
|
|
213
|
+
return drop("no evidence");
|
|
214
|
+
const secret = scanForSecrets(JSON.stringify(shaped));
|
|
215
|
+
if (secret)
|
|
216
|
+
return drop(`contains ${secret}`);
|
|
217
|
+
if (changes.length >= ctx.maxChanges)
|
|
218
|
+
return drop(`over maxChanges (${ctx.maxChanges})`);
|
|
219
|
+
changes.push(shaped);
|
|
220
|
+
});
|
|
221
|
+
return { changes, dropped };
|
|
222
|
+
}
|
|
223
|
+
const MODEL_NAME = /^[A-Za-z0-9][A-Za-z0-9.:_[\]-]{0,63}$/;
|
|
224
|
+
const DREAM_TIMEOUT_S = 600;
|
|
225
|
+
export const defaultDreamRunner = async (request, project, phrenPath) => {
|
|
226
|
+
const choice = helperFor(phrenPath, project);
|
|
227
|
+
if (request.model && MODEL_NAME.test(request.model))
|
|
228
|
+
choice.model = request.model;
|
|
229
|
+
const result = await runHelper(choice, { prompt: request.prompt, cwd: request.cwd, timeoutSeconds: request.timeoutSeconds, signal: request.signal });
|
|
230
|
+
return { ok: result.ok, output: result.output, model: result.model, ...(result.costUSD !== undefined ? { costUSD: result.costUSD } : {}), durationMs: result.durationMs };
|
|
231
|
+
};
|
|
232
|
+
export function newRunId(now) {
|
|
233
|
+
return `${now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z")}-${crypto.randomBytes(3).toString("hex")}`;
|
|
234
|
+
}
|
|
235
|
+
export function dreamLockPath(phrenPath, project) {
|
|
236
|
+
return path.join(runtimeDir(phrenPath), `dream-${project}`);
|
|
237
|
+
}
|
|
238
|
+
export async function dream(project, opts = {}) {
|
|
239
|
+
const phrenPath = opts.phrenPath ?? findPhrenPath();
|
|
240
|
+
const dryRun = opts.dryRun === true;
|
|
241
|
+
const base = { project, dryRun, outcomes: [], dropped: [] };
|
|
242
|
+
if (!phrenPath)
|
|
243
|
+
return { ...base, status: "failed", mode: opts.mode ?? "propose", message: "No Phren store found." };
|
|
244
|
+
if (!isValidProjectName(project))
|
|
245
|
+
return { ...base, status: "failed", mode: opts.mode ?? "propose", message: `Invalid project name: "${project}".` };
|
|
246
|
+
const config = { ...readDreamConfig(phrenPath, project), ...opts.config };
|
|
247
|
+
const mode = opts.mode ?? config.mode;
|
|
248
|
+
if (!config.enabled && !opts.force) {
|
|
249
|
+
return { ...base, status: "disabled", mode, message: `Dreaming is off for ${project} (dreaming.enabled). Use --force for a manual run.` };
|
|
250
|
+
}
|
|
251
|
+
const release = tryFileLock(dreamLockPath(phrenPath, project));
|
|
252
|
+
if (!release)
|
|
253
|
+
return { ...base, status: "busy", mode, message: `A dream is already running for ${project}.` };
|
|
254
|
+
try {
|
|
255
|
+
const now = opts.now ?? new Date();
|
|
256
|
+
const last = readLastRun(phrenPath, project);
|
|
257
|
+
const fromMs = last ? Date.parse(last.to) : now.getTime() - config.lookbackHours * 3_600_000;
|
|
258
|
+
const from = new Date(Math.min(fromMs, now.getTime()));
|
|
259
|
+
const versions = findingVersions(phrenPath, project);
|
|
260
|
+
const inputs = await collect(phrenPath, project, {
|
|
261
|
+
...opts.collect, from, to: now, injectBudgetKB: config.injectBudgetKB,
|
|
262
|
+
});
|
|
263
|
+
const watermark = inputs.unresolvedTranscripts ? inputs.from : inputs.to;
|
|
264
|
+
const collectionNotice = inputs.unresolvedTranscripts ? ` Skipped ${inputs.unresolvedTranscripts} OpenCode transcripts without directory metadata; watermark unchanged.` : "";
|
|
265
|
+
const report = collectionNotice ? { warnings: [collectionNotice.trim()] } : {};
|
|
266
|
+
const runId = newRunId(now);
|
|
267
|
+
const changesetBase = {
|
|
268
|
+
project, runId, startedAt: now.toISOString(), lookback: { from: inputs.from, to: inputs.to },
|
|
269
|
+
inputs: { transcripts: inputs.transcripts.length, findings: inputs.findings.length, truths: inputs.truths.length, pages: inputs.pages.length },
|
|
270
|
+
};
|
|
271
|
+
if (!inputs.transcripts.length && !inputs.budget.over && !opts.force) {
|
|
272
|
+
if (!dryRun)
|
|
273
|
+
writeLastRun(phrenPath, project, { runId, startedAt: changesetBase.startedAt, finishedAt: new Date().toISOString(), to: watermark, mode, status: "empty", trigger: opts.trigger ?? "manual" });
|
|
274
|
+
return { ...base, status: "empty", mode, runId, ...report, message: `No sessions in ${project} since ${inputs.from}; nothing to dream about.${collectionNotice}` };
|
|
275
|
+
}
|
|
276
|
+
const phases = config.phases;
|
|
277
|
+
const prompt = buildDreamPrompt(inputs, { phases, maxChanges: config.maxChanges, now });
|
|
278
|
+
const cwd = inputs.repoDir ?? projectStoreDir(phrenPath, project);
|
|
279
|
+
let reply;
|
|
280
|
+
try {
|
|
281
|
+
reply = await (opts.runner ?? defaultDreamRunner)({ prompt, cwd, timeoutSeconds: opts.timeoutSeconds ?? DREAM_TIMEOUT_S, signal: opts.signal, ...(config.model ? { model: config.model } : {}) }, project, phrenPath);
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
reply = { ok: false, output: err instanceof Error ? err.message : String(err) };
|
|
285
|
+
}
|
|
286
|
+
const spend = sanitizeDream({ ...(reply.model ? { model: reply.model } : {}), ...(reply.costUSD !== undefined ? { costUSD: reply.costUSD } : {}) });
|
|
287
|
+
const fail = (message) => {
|
|
288
|
+
if (!dryRun)
|
|
289
|
+
writeLastRun(phrenPath, project, { runId, startedAt: changesetBase.startedAt, finishedAt: new Date().toISOString(), to: last?.to ?? inputs.from, mode, status: "failed", trigger: opts.trigger ?? "manual" });
|
|
290
|
+
return { ...base, status: "failed", mode, runId, ...report, message: redactSecretsForLog(message), ...spend };
|
|
291
|
+
};
|
|
292
|
+
if (!reply.ok)
|
|
293
|
+
return fail(`The dreaming model failed: ${redactSecretsForLog(reply.output).slice(0, 500)}`);
|
|
294
|
+
const parsed = parseChangesetJson(reply.output);
|
|
295
|
+
if (!parsed.ok)
|
|
296
|
+
return fail(parsed.error);
|
|
297
|
+
const { changes, dropped } = validateChanges(parsed.value.changes, {
|
|
298
|
+
fids: new Set(inputs.findings.map(f => f.fid)), truths: inputs.truths, topics: new Set(inputs.topics.map(t => t.slug)),
|
|
299
|
+
phases, maxChanges: config.maxChanges,
|
|
300
|
+
});
|
|
301
|
+
const changeset = { ...changesetBase, changes, notes: redactSecretsForLog(parsed.value.notes).slice(0, 2_000) };
|
|
302
|
+
if (dryRun) {
|
|
303
|
+
return { ...base, status: "ok", mode, runId, ...report, changeset, dropped, counts: countOutcomes([], dropped), ...spend,
|
|
304
|
+
message: `Dry run: ${changes.length} changes would be ${mode === "apply" ? "applied" : "proposed"}, ${dropped.length} dropped.` };
|
|
305
|
+
}
|
|
306
|
+
const outcomes = await applyChangeset(phrenPath, changeset, { mode, injectBudgetKB: config.injectBudgetKB, ...(spend.model ? { model: spend.model } : {}) });
|
|
307
|
+
const finishedAt = new Date().toISOString();
|
|
308
|
+
const record = recordDream(phrenPath, project, { changeset, findingVersions: versions, ...report, mode, ...spend, finishedAt, outcomes, dropped });
|
|
309
|
+
const counts = countOutcomes(outcomes, dropped);
|
|
310
|
+
writeLastRun(phrenPath, project, { runId, startedAt: changeset.startedAt, finishedAt, to: watermark, mode, status: "ok", counts, trigger: opts.trigger ?? "manual" });
|
|
311
|
+
return { ...base, status: "ok", mode, runId, ...report, changeset, outcomes, dropped, counts, record, ...spend,
|
|
312
|
+
message: `${project}: ${counts.applied} applied, ${counts.proposed} proposed, ${counts.skipped} skipped, ${counts.failed} failed, ${counts.dropped} dropped.${collectionNotice}` };
|
|
313
|
+
}
|
|
314
|
+
finally {
|
|
315
|
+
release();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type DreamFindingType = "decision" | "pitfall" | "pattern" | "bug";
|
|
2
|
+
export interface DreamEvidence {
|
|
3
|
+
kind: "transcript" | "code" | "git" | "finding";
|
|
4
|
+
/** session id+turn, path:line, sha, or fid */
|
|
5
|
+
ref: string;
|
|
6
|
+
quote?: string;
|
|
7
|
+
}
|
|
8
|
+
export type DreamChange = {
|
|
9
|
+
op: "add_finding";
|
|
10
|
+
text: string;
|
|
11
|
+
findingType?: DreamFindingType;
|
|
12
|
+
topic?: string;
|
|
13
|
+
evidence: DreamEvidence[];
|
|
14
|
+
} | {
|
|
15
|
+
op: "supersede";
|
|
16
|
+
findingId: string;
|
|
17
|
+
newText: string;
|
|
18
|
+
evidence: DreamEvidence[];
|
|
19
|
+
} | {
|
|
20
|
+
op: "retract";
|
|
21
|
+
findingId: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
evidence: DreamEvidence[];
|
|
24
|
+
} | {
|
|
25
|
+
op: "edit";
|
|
26
|
+
findingId: string;
|
|
27
|
+
newText: string;
|
|
28
|
+
evidence: DreamEvidence[];
|
|
29
|
+
} | {
|
|
30
|
+
op: "merge";
|
|
31
|
+
findingIds: string[];
|
|
32
|
+
newText: string;
|
|
33
|
+
evidence: DreamEvidence[];
|
|
34
|
+
} | {
|
|
35
|
+
op: "move_topic";
|
|
36
|
+
findingId: string;
|
|
37
|
+
topic: string;
|
|
38
|
+
} | {
|
|
39
|
+
op: "promote_truth";
|
|
40
|
+
findingId: string;
|
|
41
|
+
text: string;
|
|
42
|
+
evidence: DreamEvidence[];
|
|
43
|
+
} | {
|
|
44
|
+
op: "demote_truth";
|
|
45
|
+
truth: string;
|
|
46
|
+
reason: string;
|
|
47
|
+
} | {
|
|
48
|
+
op: "write_page";
|
|
49
|
+
page: string;
|
|
50
|
+
markdown: string;
|
|
51
|
+
links: string[];
|
|
52
|
+
} | {
|
|
53
|
+
op: "link";
|
|
54
|
+
findingId: string;
|
|
55
|
+
entity: string;
|
|
56
|
+
};
|
|
57
|
+
export type DreamOp = DreamChange["op"];
|
|
58
|
+
export interface DreamChangeset {
|
|
59
|
+
project: string;
|
|
60
|
+
runId: string;
|
|
61
|
+
startedAt: string;
|
|
62
|
+
lookback: {
|
|
63
|
+
from: string;
|
|
64
|
+
to: string;
|
|
65
|
+
};
|
|
66
|
+
inputs: {
|
|
67
|
+
transcripts: number;
|
|
68
|
+
findings: number;
|
|
69
|
+
truths: number;
|
|
70
|
+
pages: number;
|
|
71
|
+
};
|
|
72
|
+
changes: DreamChange[];
|
|
73
|
+
notes: string;
|
|
74
|
+
}
|
|
@@ -33,12 +33,12 @@ export declare function buildLifecycleComments(lifecycle: Partial<FindingLifecyc
|
|
|
33
33
|
export declare function stripLifecycleComments(line: string): string;
|
|
34
34
|
export declare function isInactiveFindingLine(line: string): boolean;
|
|
35
35
|
export type ContradictionResolution = "keep_a" | "keep_b" | "keep_both" | "retract_both";
|
|
36
|
-
export declare function supersedeFinding(phrenPath: string, project: string, findingText: string, supersededBy: string): PhrenResult<{
|
|
36
|
+
export declare function supersedeFinding(phrenPath: string, project: string, findingText: string, supersededBy: string, expectedFindings?: Record<string, string>): PhrenResult<{
|
|
37
37
|
finding: string;
|
|
38
38
|
superseded_by: string;
|
|
39
39
|
status: FindingLifecycleStatus;
|
|
40
40
|
}>;
|
|
41
|
-
export declare function retractFinding(phrenPath: string, project: string, findingText: string, reason: string): PhrenResult<{
|
|
41
|
+
export declare function retractFinding(phrenPath: string, project: string, findingText: string, reason: string, expectedFindings?: Record<string, string>): PhrenResult<{
|
|
42
42
|
finding: string;
|
|
43
43
|
reason: string;
|
|
44
44
|
status: FindingLifecycleStatus;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
|
+
import { assertFindingVersions } from "./versions.js";
|
|
2
3
|
import * as path from "path";
|
|
3
4
|
import { renameOverSync } from "../phren-paths.js";
|
|
4
5
|
import { PhrenError, phrenErr, phrenOk } from "../phren-core.js";
|
|
@@ -218,7 +219,7 @@ function findingsPathForProject(phrenPath, project) {
|
|
|
218
219
|
return phrenErr(`No FINDINGS.md found for "${project}".`, PhrenError.FILE_NOT_FOUND);
|
|
219
220
|
return phrenOk(findingsPath);
|
|
220
221
|
}
|
|
221
|
-
export function supersedeFinding(phrenPath, project, findingText, supersededBy) {
|
|
222
|
+
export function supersedeFinding(phrenPath, project, findingText, supersededBy, expectedFindings) {
|
|
222
223
|
const pathResult = findingsPathForProject(phrenPath, project);
|
|
223
224
|
if (!pathResult.ok)
|
|
224
225
|
return pathResult;
|
|
@@ -227,6 +228,7 @@ export function supersedeFinding(phrenPath, project, findingText, supersededBy)
|
|
|
227
228
|
if (!ref)
|
|
228
229
|
return phrenErr("superseded_by cannot be empty.", PhrenError.EMPTY_INPUT);
|
|
229
230
|
return withFileLock(findingsPath, () => {
|
|
231
|
+
assertFindingVersions(findingsPath, expectedFindings);
|
|
230
232
|
const lines = fs.readFileSync(findingsPath, "utf8").split("\n");
|
|
231
233
|
const matched = matchFinding(lines, findingText);
|
|
232
234
|
if (!matched.ok)
|
|
@@ -240,7 +242,7 @@ export function supersedeFinding(phrenPath, project, findingText, supersededBy)
|
|
|
240
242
|
return phrenOk({ finding: matched.data.text, superseded_by: ref, status: "superseded" });
|
|
241
243
|
});
|
|
242
244
|
}
|
|
243
|
-
export function retractFinding(phrenPath, project, findingText, reason) {
|
|
245
|
+
export function retractFinding(phrenPath, project, findingText, reason, expectedFindings) {
|
|
244
246
|
const pathResult = findingsPathForProject(phrenPath, project);
|
|
245
247
|
if (!pathResult.ok)
|
|
246
248
|
return pathResult;
|
|
@@ -249,6 +251,7 @@ export function retractFinding(phrenPath, project, findingText, reason) {
|
|
|
249
251
|
if (!reasonText)
|
|
250
252
|
return phrenErr("reason cannot be empty.", PhrenError.EMPTY_INPUT);
|
|
251
253
|
return withFileLock(findingsPath, () => {
|
|
254
|
+
assertFindingVersions(findingsPath, expectedFindings);
|
|
252
255
|
const lines = fs.readFileSync(findingsPath, "utf8").split("\n");
|
|
253
256
|
const matched = matchFinding(lines, findingText);
|
|
254
257
|
if (!matched.ok)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Hash stored bullets and citations, including every lifecycle/provenance comment. */
|
|
2
|
+
export declare function readFindingVersions(file: string): Record<string, string>;
|
|
3
|
+
/** Called under the writer's findings lock, immediately before mutation. */
|
|
4
|
+
export declare function assertFindingVersions(file: string, expected?: Record<string, string>): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as crypto from "crypto";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import { isCitationLine } from "../content/metadata.js";
|
|
4
|
+
/** Hash stored bullets and citations, including every lifecycle/provenance comment. */
|
|
5
|
+
export function readFindingVersions(file) {
|
|
6
|
+
let lines;
|
|
7
|
+
try {
|
|
8
|
+
lines = fs.readFileSync(file, "utf8").split("\n");
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
const versions = {};
|
|
14
|
+
for (let i = 0; i < lines.length; i++) {
|
|
15
|
+
const fid = /^- .*<!--\s*fid:([a-f0-9]{8})\s*-->/.exec(lines[i])?.[1];
|
|
16
|
+
if (fid)
|
|
17
|
+
versions[fid] = crypto.createHash("sha256").update(lines[i] + (isCitationLine(lines[i + 1] ?? "") ? `\n${lines[i + 1]}` : "")).digest("hex");
|
|
18
|
+
}
|
|
19
|
+
return versions;
|
|
20
|
+
}
|
|
21
|
+
/** Called under the writer's findings lock, immediately before mutation. */
|
|
22
|
+
export function assertFindingVersions(file, expected) {
|
|
23
|
+
if (!expected)
|
|
24
|
+
return;
|
|
25
|
+
const current = readFindingVersions(file);
|
|
26
|
+
if (Object.entries(expected).some(([fid, version]) => !version || current[fid] !== version))
|
|
27
|
+
throw new Error("target finding missing or changed since the run");
|
|
28
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -335,6 +335,7 @@ async function main() {
|
|
|
335
335
|
import("./tools/config.js"),
|
|
336
336
|
import("./tools/notes.js"),
|
|
337
337
|
import("./tools/summaries.js"),
|
|
338
|
+
import("./tools/dream.js"),
|
|
338
339
|
...(codeAvailable ? [import("./tools/code.js")] : []),
|
|
339
340
|
...(hasModule("conductor") ? [import("./tools/dispatch.js"), import("./tools/helper.js")] : []),
|
|
340
341
|
]);
|
package/dist/modules/registry.js
CHANGED
|
@@ -22,13 +22,14 @@ export const BUILTIN_MODULES = [
|
|
|
22
22
|
"list_skills", "read_skill", "write_skill", "remove_skill", "toggle_skill",
|
|
23
23
|
"list_hooks", "toggle_hooks", "add_custom_hook", "remove_custom_hook", "get_config", "set_config",
|
|
24
24
|
"get_notes", "add_note", "edit_note", "remove_note", "promote_note", "get_topic_summaries", "set_topic_summary",
|
|
25
|
+
"dream_run", "dream_status", "dream_log", "dream_apply",
|
|
25
26
|
]),
|
|
26
27
|
],
|
|
27
28
|
cliCommands: [
|
|
28
29
|
"init", "quickstart", "add", "agent", "projects", "search", "status", "doctor", "web-ui", "graph", "shell",
|
|
29
30
|
"add-finding", "pin", "review", "session-context", "sessions", "finding", "note", "notes",
|
|
30
31
|
"search-fragments", "related-docs", "truths", "promote", "skills", "detect-skills", "hooks", "config",
|
|
31
|
-
"maintain", "consolidation-status", "quality-feedback", "mcp-mode", "hooks-mode", "preset", "snippet",
|
|
32
|
+
"maintain", "dream", "consolidation-status", "quality-feedback", "mcp-mode", "hooks-mode", "preset", "snippet",
|
|
32
33
|
"verify", "uninstall", "update", "profile", "store", "team", "modules list", "modules enable", "modules disable",
|
|
33
34
|
"hook-prompt", "hook-session-start", "hook-stop", "hook-context", "hook-tool", "background-sync",
|
|
34
35
|
"background-maintenance", "background-reindex", "debug-injection", "inspect-index", "skill-list",
|
|
@@ -45,7 +46,7 @@ export const BUILTIN_MODULES = [
|
|
|
45
46
|
storeFiles: [
|
|
46
47
|
"phren.root.yaml", "machines.yaml", "profiles/*.yaml", ".config/modules.yaml", ".config/*.json",
|
|
47
48
|
"<project>/AGENTS.md", "<project>/summary.md", "<project>/FINDINGS.md", "<project>/truths.md",
|
|
48
|
-
"<project>/review.md", "<project>/notes/*.md", "<project>/reference/**", "<project>/skills/**",
|
|
49
|
+
"<project>/review.md", "<project>/notes/*.md", "<project>/reference/**", "<project>/skills/**", "<project>/dreams/**",
|
|
49
50
|
"<project>/phren.project.yaml", "<project>/preferences.json", ".runtime/sessions/session-*.json",
|
|
50
51
|
".runtime/sessions/last-summary.json",
|
|
51
52
|
],
|
|
@@ -68,7 +69,7 @@ export const BUILTIN_MODULES = [
|
|
|
68
69
|
tools: [],
|
|
69
70
|
cliCommands: [
|
|
70
71
|
"bridge", "bridge install", "bridge update", "bridge uninstall", "bridge rollback", "bridge status",
|
|
71
|
-
"bridge doctor", "bridge usage", "bridge usage-statusline", "bridge hook", "bridge serve", "bridge ssh", "pair",
|
|
72
|
+
"browser", "bridge doctor", "bridge usage", "bridge usage-statusline", "bridge hook", "bridge serve", "bridge ssh", "pair",
|
|
72
73
|
"bridge fanouts archive", "bridge accounts", "bridge askpass", "canary", "computers", "computers mcp", "usage", "sudo",
|
|
73
74
|
],
|
|
74
75
|
agentHooks: [
|
|
@@ -78,9 +79,10 @@ export const BUILTIN_MODULES = [
|
|
|
78
79
|
],
|
|
79
80
|
hookRoutes: [
|
|
80
81
|
...routes("GET", ["/v1/approval-rules"]),
|
|
82
|
+
...routes("DELETE", ["/v1/browsers/recordings"]),
|
|
81
83
|
...routes("POST", ["/v1/approval-rules"]), ...routes("DELETE", ["/v1/approval-rules"]),
|
|
82
84
|
...routes("GET", [
|
|
83
|
-
"/v1/health", "/v1/health/details", "/v1/health/peers", "/v1/muxes", "/v1/terminals/resolve", "/v1/activity", "/v1/metrics", "/v1/web-servers", "/v1/simulators",
|
|
85
|
+
"/v1/health", "/v1/health/details", "/v1/health/peers", "/v1/muxes", "/v1/terminals/resolve", "/v1/activity", "/v1/metrics", "/v1/web-servers", "/v1/simulators", "/v1/browsers", "/v1/browsers/recordings", "/v1/browsers/recordings/index", "/v1/browsers/recordings/frame",
|
|
84
86
|
"/v1/simulators/screenshot", "/v1/simulators/apps", "/v1/files", "/v1/models", "/v1/harnesses", "/v1/projects/files",
|
|
85
87
|
"/v1/uploads/image", "/v1/files/range", "/v1/files/resolve", "/v1/usage", "/v1/resources", "/v1/speech/voices", "/v1/push/status", "/v1/projects/locate", "/v1/projects/repos",
|
|
86
88
|
"/v1/workspaces", "/v1/workspaces/panes", "/v1/workspaces/layout", "/v1/transcripts/blob", "/v1/transcripts/history", "/v1/sudo",
|
|
@@ -94,15 +96,15 @@ export const BUILTIN_MODULES = [
|
|
|
94
96
|
"/v1/approvals/answer", "/v1/questions/answer", "/v1/subagents/resume", "/v1/subagents/archive-finished", "/v1/canary",
|
|
95
97
|
"/v1/speech", "/v1/sudo/answer", "/v1/jobs/cleanup",
|
|
96
98
|
]),
|
|
97
|
-
...routes("WS", ["/v1/transcripts", "/v1/status", "/v1/overview", "/v1/speech/transcribe", "/v1/speech/live", "/v1/simulators/stream"]),
|
|
99
|
+
...routes("WS", ["/v1/transcripts", "/v1/status", "/v1/overview", "/v1/speech/transcribe", "/v1/speech/live", "/v1/simulators/stream", "/v1/browsers/stream"]),
|
|
98
100
|
],
|
|
99
101
|
capabilities: [
|
|
100
102
|
"hook", "transcript", "progress", "images", "prompt", "stop", "terminal", "shell", "paneTerminal", "paneLayout", "deskPresence", "herdr", "terminalResolve",
|
|
101
103
|
"webServers", "webPreview", "activity", "approvals", "questions", "accountUsage", "providers",
|
|
102
|
-
"files", "repositoryFiles", "fileResolution", "subagents", "sideQuestions", "approvalPush", "simulators", "simulatorStream", "simulatorDevices", "simulatorDrag", "overviewStream", "speech", "speechTimestamps", "speechTimestampStream", "speechLive", "speechVoices", "speechFormats", "transcribe", "promptOnce", "promptStatus", "afterTurnQueue", "queuedMessageActions", "deliveryFrames", "resources", "sessionRename", "sessionSeen", "sudo", "sudoOutcome", "previewDeltas", "quickChat", "agentFolder", "launchPermissionMode", "sessionMove", "moveNewChat", "moveConductor", "moveToComputer", "moveResume", "moveSummaryByTarget", "moveConversationCopy", "claudeAccountAdd", "accountPools", "workerRelocation", "conversationSearch",
|
|
104
|
+
"files", "repositoryFiles", "fileResolution", "subagents", "sideQuestions", "approvalPush", "browsers", "simulators", "simulatorStream", "simulatorDevices", "simulatorDrag", "overviewStream", "speech", "speechTimestamps", "speechTimestampStream", "speechLive", "speechVoices", "speechFormats", "transcribe", "promptOnce", "promptStatus", "afterTurnQueue", "queuedMessageActions", "deliveryFrames", "resources", "sessionRename", "sessionSeen", "sudo", "sudoOutcome", "previewDeltas", "quickChat", "agentFolder", "launchPermissionMode", "sessionMove", "moveNewChat", "moveConductor", "moveToComputer", "moveResume", "moveSummaryByTarget", "moveConversationCopy", "claudeAccountAdd", "accountPools", "workerRelocation", "conversationSearch",
|
|
103
105
|
],
|
|
104
106
|
storeFiles: [".runtime/sessions/opencode-*.events.jsonl", ".runtime/approvals/opencode-*.json"],
|
|
105
|
-
localFiles: ["<bridge>/turn-queue.json", "<bridge>/gitboy-webhooks.json", "<bridge>/installed.json", "<bridge>/versions/**", "<bridge>/current", "<bridge>/dispatch", "<bridge>/askpass", "<bridge>/computer-id", "<bridge>/move-intents/*.json", "<bridge>/move-intents/*.conversation.md", "<bridge>/canary.json", "<bridge>/canary-daily", "<bridge>/moves/*.json", "<bridge>/move-launches/*.json", "<bridge>/conversation-search.sqlite", "<bridge>/conversation-search-rows/**"],
|
|
107
|
+
localFiles: ["<bridge>/turn-queue.json", "<bridge>/gitboy-webhooks.json", "<bridge>/installed.json", "<bridge>/versions/**", "<bridge>/current", "<bridge>/dispatch", "<bridge>/askpass", "<bridge>/browser.sock", "<bridge>/browser-recordings/**", "<bridge>/computer-id", "<bridge>/move-intents/*.json", "<bridge>/move-intents/*.conversation.md", "<bridge>/canary.json", "<bridge>/canary-daily", "<bridge>/moves/*.json", "<bridge>/move-launches/*.json", "<bridge>/conversation-search.sqlite", "<bridge>/conversation-search-rows/**"],
|
|
106
108
|
phoneScreens: [{ screen: "LiveSessionsView", capability: "hook" }, { screen: "AgentChatView", capability: "transcript" }],
|
|
107
109
|
skills: [],
|
|
108
110
|
},
|
package/dist/project-config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RetentionPolicyPatch } from "./governance/policy.js";
|
|
2
|
+
import type { DreamingConfig } from "./config/dreaming.js";
|
|
2
3
|
export declare const PROJECT_OWNERSHIP_MODES: readonly ["phren-managed", "detached", "repo-managed"];
|
|
3
4
|
export type ProjectOwnershipMode = typeof PROJECT_OWNERSHIP_MODES[number];
|
|
4
5
|
export interface ProjectMcpServerEntry {
|
|
@@ -17,6 +18,8 @@ export interface ProjectConfigOverrides {
|
|
|
17
18
|
lowConfidenceThreshold?: number;
|
|
18
19
|
riskySections?: Array<"Review" | "Stale" | "Conflicts">;
|
|
19
20
|
};
|
|
21
|
+
/** Per-project overrides of the `dreaming` domain (config/dreaming.ts). */
|
|
22
|
+
dreaming?: Partial<DreamingConfig>;
|
|
20
23
|
}
|
|
21
24
|
export interface ProjectAccessControl {
|
|
22
25
|
admins?: string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Private-store links only. Never encode a task identity in Git or forge data. */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const mergeTaskIdentitySchema: z.ZodObject<{
|
|
4
|
+
storeId: z.ZodString;
|
|
5
|
+
project: z.ZodString;
|
|
6
|
+
stableId: z.ZodString;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export declare const branchLinkSchema: z.ZodObject<{
|
|
9
|
+
repo: z.ZodString;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const prLinkSchema: z.ZodObject<{
|
|
13
|
+
repo: z.ZodString;
|
|
14
|
+
number: z.ZodNumber;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export declare const taskLinksSchema: z.ZodObject<{
|
|
17
|
+
version: z.ZodLiteral<1>;
|
|
18
|
+
branches: z.ZodArray<z.ZodObject<{
|
|
19
|
+
repo: z.ZodString;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
}, z.core.$strict>>;
|
|
22
|
+
prs: z.ZodArray<z.ZodObject<{
|
|
23
|
+
repo: z.ZodString;
|
|
24
|
+
number: z.ZodNumber;
|
|
25
|
+
}, z.core.$strict>>;
|
|
26
|
+
review: z.ZodOptional<z.ZodEnum<{
|
|
27
|
+
"closed, review": "closed, review";
|
|
28
|
+
"merged, verify": "merged, verify";
|
|
29
|
+
}>>;
|
|
30
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export type TaskLinks = z.infer<typeof taskLinksSchema>;
|
|
33
|
+
export type PrLink = z.infer<typeof prLinkSchema>;
|
|
34
|
+
export declare function prUrl(pr: PrLink): string;
|
|
35
|
+
export declare function parsePrLink(value: string): PrLink | undefined;
|
|
36
|
+
export declare function uniqueLinks<T>(links: T[]): T[];
|
|
37
|
+
/** Bare #N is deliberately ignored. Bare branch names need a trusted project repo. */
|
|
38
|
+
export declare function linksFromContext(context: string, projectRepo?: string): TaskLinks;
|