synthesisui 0.16.12 → 0.16.13
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/agent-wiring.js +22 -7
- package/package.json +1 -1
package/dist/agent-wiring.js
CHANGED
|
@@ -36,6 +36,15 @@ export async function hookCommand(root, version) {
|
|
|
36
36
|
? "npx --no-install synthesisui hook"
|
|
37
37
|
: `npx synthesisui@${version} hook`;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the command that IS in the file, not the one we would have written.
|
|
41
|
+
*
|
|
42
|
+
* On a project already wired by hand, `connect` reported "already had it" and
|
|
43
|
+
* then printed the npx command it had not written - and, keying off that same
|
|
44
|
+
* string, advised about a 0.7s cost the installed hook does not pay (caught by
|
|
45
|
+
* the owner reading the output against the file, 27/07). Two wrong sentences
|
|
46
|
+
* from one wrong variable, and both point somebody at the wrong thing to debug.
|
|
47
|
+
*/
|
|
39
48
|
async function wireHook(root, command) {
|
|
40
49
|
const dir = join(root, ".claude");
|
|
41
50
|
const path = join(dir, "settings.json");
|
|
@@ -45,16 +54,18 @@ async function wireHook(root, command) {
|
|
|
45
54
|
// Idempotent on the COMMAND, not on the whole entry: someone may have
|
|
46
55
|
// widened the matcher or added a second hook beside ours, and running this
|
|
47
56
|
// again must not undo that.
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
const mine = post
|
|
58
|
+
.flatMap((e) => e.hooks ?? [])
|
|
59
|
+
.find((h) => (h.command ?? "").includes("synthesisui"));
|
|
60
|
+
if (mine)
|
|
61
|
+
return { status: "already there", command: mine.command ?? command };
|
|
51
62
|
post.push({
|
|
52
63
|
matcher: HOOK_MATCHER,
|
|
53
64
|
hooks: [{ type: "command", command }],
|
|
54
65
|
});
|
|
55
66
|
await mkdir(dir, { recursive: true });
|
|
56
67
|
await writeFile(path, `${JSON.stringify({ ...settings, hooks: { ...hooks, PostToolUse: post } }, null, 2)}\n`, "utf8");
|
|
57
|
-
return "added";
|
|
68
|
+
return { status: "added", command };
|
|
58
69
|
}
|
|
59
70
|
async function wireMcp(root, version) {
|
|
60
71
|
const path = join(root, ".mcp.json");
|
|
@@ -79,10 +90,14 @@ async function wireMcp(root, version) {
|
|
|
79
90
|
return "added";
|
|
80
91
|
}
|
|
81
92
|
export async function wireAgent(root, version, want) {
|
|
82
|
-
const
|
|
93
|
+
const proposed = await hookCommand(root, version);
|
|
94
|
+
const hook = want.hook
|
|
95
|
+
? await wireHook(root, proposed)
|
|
96
|
+
: { status: "skipped", command: proposed };
|
|
83
97
|
return {
|
|
84
|
-
|
|
85
|
-
|
|
98
|
+
// What is actually installed - the only thing worth printing.
|
|
99
|
+
command: hook.command,
|
|
100
|
+
hook: hook.status,
|
|
86
101
|
mcp: want.mcp ? await wireMcp(root, version) : "skipped",
|
|
87
102
|
};
|
|
88
103
|
}
|
package/package.json
CHANGED