@phren/cli 0.3.1 → 0.3.3
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/agent-hooks.d.ts +5 -0
- package/dist/bridge/agent-hooks.js +19 -0
- package/dist/bridge/command.d.ts +3 -2
- package/dist/bridge/command.js +5 -3
- package/dist/bridge/push.d.ts +42 -3
- package/dist/bridge/push.js +90 -20
- package/dist/bridge/server-pane-routes.js +11 -5
- package/dist/bridge/server-routes.d.ts +1 -0
- package/dist/bridge/server-routes.js +1 -1
- package/dist/bridge/speech.d.ts +28 -0
- package/dist/bridge/speech.js +87 -5
- package/dist/bridge-hook.mjs +206 -31
- package/dist/cli/namespaces-store.js +83 -2
- package/dist/cli-registry.js +1 -1
- package/dist/init/init-walkthrough.js +1 -1
- package/dist/link/link.js +9 -3
- package/dist/link/refresh.js +11 -10
- package/dist/modules/registry.js +1 -1
- package/dist/sync/conflict-resolve.d.ts +1 -1
- package/dist/sync/conflict-resolve.js +44 -7
- package/dist/tools/search.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resolves the content conflicts a store merge can settle without a person:
|
|
3
|
-
* tasks.md per task id against the merge base, generated
|
|
4
|
-
* incoming side, and the
|
|
5
|
-
*
|
|
3
|
+
* tasks.md per task id against the merge base, generated summaries from the
|
|
4
|
+
* incoming side, and the append-only record files (findings, notes, journal,
|
|
5
|
+
* review queue, topic archives) as a union of both sides. Everything else
|
|
6
|
+
* stays conflicted so the caller aborts and names it.
|
|
7
|
+
*
|
|
8
|
+
* Any file left unresolved aborts the whole merge, and every later auto-save
|
|
9
|
+
* then commits locally and fails to push, so a store drifts further from its
|
|
10
|
+
* remote each session. Every file phren itself writes during normal use needs
|
|
11
|
+
* a strategy here.
|
|
6
12
|
*/
|
|
7
13
|
import { execFileSync, spawnSync } from "child_process";
|
|
8
14
|
import * as crypto from "crypto";
|
|
@@ -29,6 +35,10 @@ export function conflictStrategy(relFile) {
|
|
|
29
35
|
return "topic";
|
|
30
36
|
if (name === "summary.md")
|
|
31
37
|
return "summary";
|
|
38
|
+
if (name === "review.md")
|
|
39
|
+
return "union";
|
|
40
|
+
if (/(^|\/)(notes|journal)\/[^/]+\.md$/i.test(file))
|
|
41
|
+
return "union";
|
|
32
42
|
return null;
|
|
33
43
|
}
|
|
34
44
|
function git(cwd, args) {
|
|
@@ -71,15 +81,38 @@ function mergeText(base, ours, theirs) {
|
|
|
71
81
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
72
82
|
}
|
|
73
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* A line-level three-way merge that keeps both sides of a conflicting hunk,
|
|
86
|
+
* local lines first (`git merge-file --union`). For append-only records two
|
|
87
|
+
* machines adding entries at the same spot is not a real conflict.
|
|
88
|
+
*/
|
|
89
|
+
function unionText(base, ours, theirs) {
|
|
90
|
+
const clean = mergeText(base, ours, theirs);
|
|
91
|
+
if (clean !== null)
|
|
92
|
+
return clean;
|
|
93
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "phren-merge-"));
|
|
94
|
+
try {
|
|
95
|
+
const [o, b, t] = ["ours", "base", "theirs"].map((name) => path.join(dir, name));
|
|
96
|
+
fs.writeFileSync(o, ours);
|
|
97
|
+
fs.writeFileSync(b, base);
|
|
98
|
+
fs.writeFileSync(t, theirs);
|
|
99
|
+
const result = spawnSync("git", ["merge-file", "--union", "-p", o, b, t], { encoding: "utf8", env: nonInteractiveGitEnv(), timeout: EXEC_TIMEOUT_MS });
|
|
100
|
+
return result.status === 0 ? result.stdout : null;
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
74
106
|
/**
|
|
75
107
|
* Generated blocks regenerate, so the incoming block wins; the rest of the
|
|
76
|
-
* file
|
|
108
|
+
* file merges with `merge`: a union of both sides by default (a topic
|
|
109
|
+
* archive's bullets).
|
|
77
110
|
*/
|
|
78
|
-
function mergeWithGeneratedBlock(base, ours, theirs, start, end, where) {
|
|
111
|
+
function mergeWithGeneratedBlock(base, ours, theirs, start, end, where, merge = unionText) {
|
|
79
112
|
const b = splitBlock(base, start, end);
|
|
80
113
|
const o = splitBlock(ours, start, end);
|
|
81
114
|
const t = splitBlock(theirs, start, end);
|
|
82
|
-
const rest =
|
|
115
|
+
const rest = merge(b.rest, o.rest, t.rest);
|
|
83
116
|
if (rest === null)
|
|
84
117
|
return null;
|
|
85
118
|
const block = t.block ?? o.block;
|
|
@@ -94,7 +127,11 @@ function resolveContent(strategy, base, ours, theirs) {
|
|
|
94
127
|
// Archived tasks only accumulate: keep both sides, the incoming version of any duplicate.
|
|
95
128
|
case "archive": return mergeTask(theirs, ours);
|
|
96
129
|
case "topic": return mergeWithGeneratedBlock(base, ours, theirs, NOW_START, NOW_END, "top");
|
|
97
|
-
|
|
130
|
+
// Summaries are regenerated from the store: when the hand-written part
|
|
131
|
+
// doesn't merge cleanly, take the incoming file whole and let the next
|
|
132
|
+
// summarize pass fold in anything only this machine had.
|
|
133
|
+
case "summary": return mergeWithGeneratedBlock(base, ours, theirs, KNOWS_START, KNOWS_END, "bottom", mergeText) ?? theirs;
|
|
134
|
+
case "union": return unionText(base, ours, theirs);
|
|
98
135
|
}
|
|
99
136
|
}
|
|
100
137
|
/** Resolves what it can in the store's in-progress merge and stages it. */
|
package/dist/tools/search.js
CHANGED
|
@@ -698,7 +698,7 @@ async function handleGetFindings(ctx, { project, limit, include_superseded, incl
|
|
|
698
698
|
if (entry.scope)
|
|
699
699
|
metadata.push(`scope=${entry.scope}`);
|
|
700
700
|
if (entry.symbol)
|
|
701
|
-
metadata.push(`
|
|
701
|
+
metadata.push(`name=${entry.symbol}`);
|
|
702
702
|
if (entry.supersedes)
|
|
703
703
|
metadata.push(`supersedes="${entry.supersedes.slice(0, 30)}"`);
|
|
704
704
|
if (entry.supersededBy)
|