@layoutdesign/context 0.6.0 → 0.10.1
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/README.md +71 -0
- package/dist/bin/cli.js +8 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/src/cli/install.d.ts +1 -0
- package/dist/src/cli/install.d.ts.map +1 -1
- package/dist/src/cli/install.js +25 -0
- package/dist/src/cli/install.js.map +1 -1
- package/dist/src/cli/live-notify.d.ts +2 -0
- package/dist/src/cli/live-notify.d.ts.map +1 -0
- package/dist/src/cli/live-notify.js +29 -0
- package/dist/src/cli/live-notify.js.map +1 -0
- package/dist/src/install/live.d.ts +5 -0
- package/dist/src/install/live.d.ts.map +1 -0
- package/dist/src/install/live.js +285 -0
- package/dist/src/install/live.js.map +1 -0
- package/dist/src/mcp/live-lock-store.d.ts +40 -0
- package/dist/src/mcp/live-lock-store.d.ts.map +1 -0
- package/dist/src/mcp/live-lock-store.js +134 -0
- package/dist/src/mcp/live-lock-store.js.map +1 -0
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +11 -0
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools/_live-socket.d.ts +23 -0
- package/dist/src/mcp/tools/_live-socket.d.ts.map +1 -0
- package/dist/src/mcp/tools/_live-socket.js +135 -0
- package/dist/src/mcp/tools/_live-socket.js.map +1 -0
- package/dist/src/mcp/tools/check-setup.d.ts +14 -1
- package/dist/src/mcp/tools/check-setup.d.ts.map +1 -1
- package/dist/src/mcp/tools/check-setup.js +75 -1
- package/dist/src/mcp/tools/check-setup.js.map +1 -1
- package/dist/src/mcp/tools/get-recent-visual-edits.d.ts +40 -0
- package/dist/src/mcp/tools/get-recent-visual-edits.d.ts.map +1 -0
- package/dist/src/mcp/tools/get-recent-visual-edits.js +106 -0
- package/dist/src/mcp/tools/get-recent-visual-edits.js.map +1 -0
- package/dist/src/mcp/tools/get-selected-element.d.ts +10 -0
- package/dist/src/mcp/tools/get-selected-element.d.ts.map +1 -0
- package/dist/src/mcp/tools/get-selected-element.js +46 -0
- package/dist/src/mcp/tools/get-selected-element.js.map +1 -0
- package/dist/src/mcp/tools/lock-file.d.ts +28 -0
- package/dist/src/mcp/tools/lock-file.d.ts.map +1 -0
- package/dist/src/mcp/tools/lock-file.js +42 -0
- package/dist/src/mcp/tools/lock-file.js.map +1 -0
- package/dist/src/mcp/tools/unlock-file.d.ts +23 -0
- package/dist/src/mcp/tools/unlock-file.d.ts.map +1 -0
- package/dist/src/mcp/tools/unlock-file.js +23 -0
- package/dist/src/mcp/tools/unlock-file.js.map +1 -0
- package/dist/src/plugins/next/babel-loader.d.ts +8 -0
- package/dist/src/plugins/next/babel-loader.d.ts.map +1 -0
- package/dist/src/plugins/next/babel-loader.js +26 -0
- package/dist/src/plugins/next/babel-loader.js.map +1 -0
- package/dist/src/plugins/next/index.d.ts +23 -0
- package/dist/src/plugins/next/index.d.ts.map +1 -0
- package/dist/src/plugins/next/index.js +58 -0
- package/dist/src/plugins/next/index.js.map +1 -0
- package/dist/src/plugins/transform.d.ts +19 -0
- package/dist/src/plugins/transform.d.ts.map +1 -0
- package/dist/src/plugins/transform.js +177 -0
- package/dist/src/plugins/transform.js.map +1 -0
- package/dist/src/plugins/vite/index.d.ts +24 -0
- package/dist/src/plugins/vite/index.d.ts.map +1 -0
- package/dist/src/plugins/vite/index.js +56 -0
- package/dist/src/plugins/vite/index.js.map +1 -0
- package/package.json +31 -9
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool: get-recent-visual-edits
|
|
3
|
+
*
|
|
4
|
+
* Returns recent class/token/inline-style edits made by the user in layout
|
|
5
|
+
* Live. Reads from Live's socket when running; falls back to the on-disk
|
|
6
|
+
* `.layout/live/recent-edits.json` log when Live is not running.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { promises as fs } from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { connectToLive } from "./_live-socket.js";
|
|
12
|
+
export const name = "get-recent-visual-edits";
|
|
13
|
+
export const description = "Returns recent visual edits made by the user in layout Live. Use this " +
|
|
14
|
+
"when the user references 'the change I just made', 'what I tweaked', or " +
|
|
15
|
+
"you need context on recent UI modifications before generating new code. " +
|
|
16
|
+
"Works even when Live is not running (reads the on-disk edit log).";
|
|
17
|
+
export const inputSchema = {
|
|
18
|
+
limit: z
|
|
19
|
+
.number()
|
|
20
|
+
.int()
|
|
21
|
+
.positive()
|
|
22
|
+
.max(100)
|
|
23
|
+
.default(20)
|
|
24
|
+
.describe("Maximum number of edits to return (most recent first)"),
|
|
25
|
+
since: z
|
|
26
|
+
.string()
|
|
27
|
+
.datetime()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Only return edits with an ISO-8601 timestamp at or after this"),
|
|
30
|
+
file: z
|
|
31
|
+
.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Filter to edits on this file (relative to project root)"),
|
|
34
|
+
};
|
|
35
|
+
const EDIT_LOG = path.join(".layout", "live", "recent-edits.json");
|
|
36
|
+
function applyFilters(edits, input) {
|
|
37
|
+
const limit = input.limit ?? 20;
|
|
38
|
+
const sinceMs = input.since ? Date.parse(input.since) : undefined;
|
|
39
|
+
let filtered = edits;
|
|
40
|
+
if (input.file) {
|
|
41
|
+
filtered = filtered.filter((e) => e.file === input.file);
|
|
42
|
+
}
|
|
43
|
+
if (sinceMs !== undefined && !Number.isNaN(sinceMs)) {
|
|
44
|
+
filtered = filtered.filter((e) => Date.parse(e.timestamp) >= sinceMs);
|
|
45
|
+
}
|
|
46
|
+
// Most recent first.
|
|
47
|
+
filtered = [...filtered].sort((a, b) => Date.parse(b.timestamp) - Date.parse(a.timestamp));
|
|
48
|
+
const truncated = filtered.length > limit;
|
|
49
|
+
return { edits: filtered.slice(0, limit), truncated };
|
|
50
|
+
}
|
|
51
|
+
async function readEditLog(projectRoot) {
|
|
52
|
+
try {
|
|
53
|
+
const raw = await fs.readFile(path.join(projectRoot, EDIT_LOG), "utf8");
|
|
54
|
+
const parsed = JSON.parse(raw);
|
|
55
|
+
if (Array.isArray(parsed))
|
|
56
|
+
return parsed;
|
|
57
|
+
if (parsed && Array.isArray(parsed.edits)) {
|
|
58
|
+
return parsed.edits;
|
|
59
|
+
}
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function handler() {
|
|
67
|
+
return async (input) => {
|
|
68
|
+
const projectRoot = process.cwd();
|
|
69
|
+
const live = await connectToLive(projectRoot);
|
|
70
|
+
let result;
|
|
71
|
+
if (live) {
|
|
72
|
+
try {
|
|
73
|
+
const res = await live.send({
|
|
74
|
+
method: "get-edits",
|
|
75
|
+
params: {
|
|
76
|
+
limit: input.limit ?? 20,
|
|
77
|
+
since: input.since,
|
|
78
|
+
file: input.file,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
result = {
|
|
82
|
+
source: "live-socket",
|
|
83
|
+
edits: res?.edits ?? [],
|
|
84
|
+
truncated: Boolean(res?.truncated),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
const all = await readEditLog(projectRoot);
|
|
89
|
+
const { edits, truncated } = applyFilters(all, input);
|
|
90
|
+
result = { source: "edit-log-file", edits, truncated };
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
live.close();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const all = await readEditLog(projectRoot);
|
|
98
|
+
const { edits, truncated } = applyFilters(all, input);
|
|
99
|
+
result = { source: "edit-log-file", edits, truncated };
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=get-recent-visual-edits.js.map
|
|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;YACN,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;YAC3C,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACtD,MAAM,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QACzD,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;SACnE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const name = "get-selected-element";
|
|
2
|
+
export declare const description: string;
|
|
3
|
+
export declare const inputSchema: {};
|
|
4
|
+
export declare function handler(): () => Promise<{
|
|
5
|
+
content: {
|
|
6
|
+
type: "text";
|
|
7
|
+
text: string;
|
|
8
|
+
}[];
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=get-selected-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-selected-element.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/get-selected-element.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,IAAI,yBAAyB,CAAC;AAE3C,eAAO,MAAM,WAAW,QAG2D,CAAC;AAGpF,eAAO,MAAM,WAAW,IAAK,CAAC;AAY9B,wBAAgB,OAAO;;;;;GA8BtB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool: get-selected-element
|
|
3
|
+
*
|
|
4
|
+
* Returns the element currently selected in the layout Live desktop app.
|
|
5
|
+
* Falls back cleanly to `{ running: false }` when Live is not running.
|
|
6
|
+
*/
|
|
7
|
+
import { connectToLive } from "./_live-socket.js";
|
|
8
|
+
export const name = "get-selected-element";
|
|
9
|
+
export const description = "Returns the element currently selected in layout Live (desktop app). " +
|
|
10
|
+
"Use this when the user says 'this', 'that one', or refers to something " +
|
|
11
|
+
"they have selected visually. Returns { running: false } if Live is not running.";
|
|
12
|
+
// No inputs — mirrors the existing raw-shape convention (e.g. get-design-system).
|
|
13
|
+
export const inputSchema = {};
|
|
14
|
+
export function handler() {
|
|
15
|
+
return async () => {
|
|
16
|
+
const live = await connectToLive();
|
|
17
|
+
if (!live) {
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{ type: "text", text: JSON.stringify({ running: false }) },
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const sel = await live.send({ method: "get-selection" });
|
|
26
|
+
const payload = sel?.selected
|
|
27
|
+
? { running: true, ...sel }
|
|
28
|
+
: { running: true, selected: false };
|
|
29
|
+
return {
|
|
30
|
+
content: [{ type: "text", text: JSON.stringify(payload) }],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Socket present but query failed — surface as not running rather than error.
|
|
35
|
+
return {
|
|
36
|
+
content: [
|
|
37
|
+
{ type: "text", text: JSON.stringify({ running: false }) },
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
live.close();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=get-selected-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-selected-element.js","sourceRoot":"","sources":["../../../../src/mcp/tools/get-selected-element.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,CAAC,MAAM,IAAI,GAAG,sBAAsB,CAAC;AAE3C,MAAM,CAAC,MAAM,WAAW,GACtB,uEAAuE;IACvE,yEAAyE;IACzE,iFAAiF,CAAC;AAEpF,kFAAkF;AAClF,MAAM,CAAC,MAA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Live desktop app don't clobber each other's edits. Backed by the atomic
|
|
6
|
+
* file-based lock store at `.layout/live/locks.json`.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
export declare const name = "lock-file";
|
|
10
|
+
export declare const description: string;
|
|
11
|
+
export declare const inputSchema: {
|
|
12
|
+
path: z.ZodString;
|
|
13
|
+
ttl_seconds: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
15
|
+
};
|
|
16
|
+
type Input = {
|
|
17
|
+
path: string;
|
|
18
|
+
ttl_seconds?: number;
|
|
19
|
+
reason?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function handler(): (input: Input) => Promise<{
|
|
22
|
+
content: {
|
|
23
|
+
type: "text";
|
|
24
|
+
text: string;
|
|
25
|
+
}[];
|
|
26
|
+
}>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=lock-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock-file.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/lock-file.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,IAAI,cAAc,CAAC;AAEhC,eAAO,MAAM,WAAW,QAID,CAAC;AAExB,eAAO,MAAM,WAAW;;;;CAavB,CAAC;AAEF,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,wBAAgB,OAAO,KACP,OAAO,KAAK;;;;;GAW3B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool: lock-file
|
|
3
|
+
*
|
|
4
|
+
* Reserves exclusive write access to a project file so Claude and the layout
|
|
5
|
+
* Live desktop app don't clobber each other's edits. Backed by the atomic
|
|
6
|
+
* file-based lock store at `.layout/live/locks.json`.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { acquireLock } from "../live-lock-store.js";
|
|
10
|
+
export const name = "lock-file";
|
|
11
|
+
export const description = "Reserves exclusive write access to a file. Call this before editing a " +
|
|
12
|
+
"file that may also be open in layout Live. Hold for the specified TTL, " +
|
|
13
|
+
"then release with unlock-file. If the lock is held by Live, retry briefly " +
|
|
14
|
+
"or notify the user.";
|
|
15
|
+
export const inputSchema = {
|
|
16
|
+
path: z.string().describe("Path relative to project root"),
|
|
17
|
+
ttl_seconds: z
|
|
18
|
+
.number()
|
|
19
|
+
.int()
|
|
20
|
+
.positive()
|
|
21
|
+
.max(300)
|
|
22
|
+
.default(60)
|
|
23
|
+
.describe("How long the lock is held before it auto-expires"),
|
|
24
|
+
reason: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Why the lock is being acquired"),
|
|
28
|
+
};
|
|
29
|
+
export function handler() {
|
|
30
|
+
return async (input) => {
|
|
31
|
+
const result = await acquireLock(process.cwd(), {
|
|
32
|
+
path: input.path,
|
|
33
|
+
ttlSeconds: input.ttl_seconds ?? 60,
|
|
34
|
+
reason: input.reason,
|
|
35
|
+
holder: "claude",
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=lock-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock-file.js","sourceRoot":"","sources":["../../../../src/mcp/tools/lock-file.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAC;AAEhC,MAAM,CAAC,MAAM,WAAW,GACtB,wEAAwE;IACxE,yEAAyE;IACzE,4EAA4E;IAC5E,qBAAqB,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAC1D,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,GAAG,CAAC,GAAG,CAAC;SACR,OAAO,CAAC,EAAE,CAAC;SACX,QAAQ,CAAC,kDAAkD,CAAC;IAC/D,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,gCAAgC,CAAC;CAC9C,CAAC;AAIF,MAAM,UAAU,OAAO;IACrB,OAAO,KAAK,EAAE,KAAY,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE;YAC9C,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,UAAU,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;YACnC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;SACnE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool: unlock-file
|
|
3
|
+
*
|
|
4
|
+
* Releases a previously-acquired file lock by its lock id. Only the entry
|
|
5
|
+
* whose `lock_id` matches is removed.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
export declare const name = "unlock-file";
|
|
9
|
+
export declare const description: string;
|
|
10
|
+
export declare const inputSchema: {
|
|
11
|
+
lock_id: z.ZodString;
|
|
12
|
+
};
|
|
13
|
+
type Input = {
|
|
14
|
+
lock_id: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function handler(): (input: Input) => Promise<{
|
|
17
|
+
content: {
|
|
18
|
+
type: "text";
|
|
19
|
+
text: string;
|
|
20
|
+
}[];
|
|
21
|
+
}>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=unlock-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlock-file.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/unlock-file.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,IAAI,gBAAgB,CAAC;AAElC,eAAO,MAAM,WAAW,QAEkD,CAAC;AAE3E,eAAO,MAAM,WAAW;;CAEvB,CAAC;AAEF,KAAK,KAAK,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,wBAAgB,OAAO,KACP,OAAO,KAAK;;;;;GAM3B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool: unlock-file
|
|
3
|
+
*
|
|
4
|
+
* Releases a previously-acquired file lock by its lock id. Only the entry
|
|
5
|
+
* whose `lock_id` matches is removed.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { releaseLock } from "../live-lock-store.js";
|
|
9
|
+
export const name = "unlock-file";
|
|
10
|
+
export const description = "Releases a previously-acquired file lock. Pass the lock_id returned by " +
|
|
11
|
+
"lock-file. A non-matching or already-expired lock_id releases nothing.";
|
|
12
|
+
export const inputSchema = {
|
|
13
|
+
lock_id: z.string().describe("The lock_id returned by a prior lock-file call"),
|
|
14
|
+
};
|
|
15
|
+
export function handler() {
|
|
16
|
+
return async (input) => {
|
|
17
|
+
const result = await releaseLock(process.cwd(), input.lock_id);
|
|
18
|
+
return {
|
|
19
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=unlock-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlock-file.js","sourceRoot":"","sources":["../../../../src/mcp/tools/unlock-file.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC;AAElC,MAAM,CAAC,MAAM,WAAW,GACtB,yEAAyE;IACzE,wEAAwE,CAAC;AAE3E,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;CAC/E,CAAC;AAIF,MAAM,UAAU,OAAO;IACrB,OAAO,KAAK,EAAE,KAAY,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/D,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;SACnE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface LoaderContext {
|
|
2
|
+
resourcePath: string;
|
|
3
|
+
rootContext: string;
|
|
4
|
+
async(): (err: Error | null, content?: string, sourceMap?: object) => void;
|
|
5
|
+
}
|
|
6
|
+
export default function layoutBabelLoader(this: LoaderContext, source: string, inputMap?: object): void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=babel-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babel-loader.d.ts","sourceRoot":"","sources":["../../../../src/plugins/next/babel-loader.ts"],"names":[],"mappings":"AASA,UAAU,aAAa;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,IAAI,CACP,GAAG,EAAE,KAAK,GAAG,IAAI,EACjB,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,KACf,IAAI,CAAC;CACX;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAmBN"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin webpack-loader wrapper around the shared layout Babel transform.
|
|
3
|
+
*
|
|
4
|
+
* Runs after Next's own Babel loader (so it sees plain JSX). Injects the
|
|
5
|
+
* layout source-location attrs in dev only. Source maps are chained back to
|
|
6
|
+
* webpack so error stacks still point at the user's original lines.
|
|
7
|
+
*/
|
|
8
|
+
import { transformWithLayoutAttrs } from "../transform.js";
|
|
9
|
+
export default function layoutBabelLoader(source, inputMap) {
|
|
10
|
+
const callback = this.async();
|
|
11
|
+
try {
|
|
12
|
+
const result = transformWithLayoutAttrs(source, this.resourcePath, this.rootContext);
|
|
13
|
+
if (result.code === source && result.map === null) {
|
|
14
|
+
// Nothing injected — pass through with the incoming map intact.
|
|
15
|
+
callback(null, source, inputMap);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
callback(null, result.code, result.map ?? inputMap);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
// Never break the dev build over an attr-injection failure.
|
|
22
|
+
callback(null, source, inputMap);
|
|
23
|
+
void err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=babel-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babel-loader.js","sourceRoot":"","sources":["../../../../src/plugins/next/babel-loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAY3D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAEvC,MAAc,EACd,QAAiB;IAEjB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAC9B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,wBAAwB,CACrC,MAAM,EACN,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,WAAW,CACjB,CAAC;QACF,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;YAClD,gEAAgE;YAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;YACjC,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,4DAA4D;QAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACjC,KAAK,GAAG,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type WebpackRule = {
|
|
2
|
+
test: RegExp;
|
|
3
|
+
exclude?: RegExp;
|
|
4
|
+
use: unknown[];
|
|
5
|
+
};
|
|
6
|
+
interface WebpackConfigLike {
|
|
7
|
+
module?: {
|
|
8
|
+
rules?: WebpackRule[];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface WebpackOptions {
|
|
12
|
+
dev: boolean;
|
|
13
|
+
defaultLoaders?: {
|
|
14
|
+
babel?: unknown;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface NextConfigLike {
|
|
18
|
+
webpack?: (config: WebpackConfigLike, options: WebpackOptions) => WebpackConfigLike;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export default function withLayout(nextConfig?: NextConfigLike): NextConfigLike;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/next/index.ts"],"names":[],"mappings":"AAkBA,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,OAAO,EAAE,CAAC;CAChB,CAAC;AAEF,UAAU,iBAAiB;IACzB,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC;CACpC;AAED,UAAU,cAAc;IACtB,GAAG,EAAE,OAAO,CAAC;IACb,cAAc,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,CACR,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,cAAc,KACpB,iBAAiB,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AASD,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,UAAU,GAAE,cAAmB,GAC9B,cAAc,CAoChB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@layoutdesign/context/next-plugin`
|
|
3
|
+
*
|
|
4
|
+
* Next.js config HOC. Adds a dev-only webpack rule that runs the shared
|
|
5
|
+
* layout Babel transform on .tsx/.jsx files (Option A from the spec — Babel
|
|
6
|
+
* via webpack; SWC plugin is a future v1.1 item). No-op in production.
|
|
7
|
+
*
|
|
8
|
+
* import withLayout from '@layoutdesign/context/next-plugin';
|
|
9
|
+
* export default withLayout({ /* ...next config *\/ });
|
|
10
|
+
*
|
|
11
|
+
* Composes cleanly with an existing user `webpack(config, options)` override:
|
|
12
|
+
* we mutate the config, then defer to the user's function if present.
|
|
13
|
+
*
|
|
14
|
+
* `next`/`webpack` are optional peers — types are kept structural so the
|
|
15
|
+
* package builds and ships without them installed.
|
|
16
|
+
*/
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
/** Absolute path to the compiled babel-loader, resolved relative to here. */
|
|
19
|
+
function babelLoaderPath() {
|
|
20
|
+
return fileURLToPath(new URL("./babel-loader.js", import.meta.url));
|
|
21
|
+
}
|
|
22
|
+
let turbopackWarned = false;
|
|
23
|
+
export default function withLayout(nextConfig = {}) {
|
|
24
|
+
// Turbopack (`next dev --turbo`, default in newer Next) ignores the
|
|
25
|
+
// `webpack()` hook, so the dev tagging below never runs and layout Live
|
|
26
|
+
// would silently fail to resolve elements. Make that explicit once
|
|
27
|
+
// rather than silent. Native Turbopack/SWC tagging is tracked separately.
|
|
28
|
+
if (process.env.TURBOPACK && !turbopackWarned) {
|
|
29
|
+
turbopackWarned = true;
|
|
30
|
+
console.warn("[@layoutdesign/context] Turbopack detected — layout Live source " +
|
|
31
|
+
"tagging needs webpack. Run `next dev` without --turbo for the " +
|
|
32
|
+
"visual-edit loop (Turbopack support is tracked, not yet shipped).");
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
...nextConfig,
|
|
36
|
+
webpack(config, options) {
|
|
37
|
+
if (options.dev) {
|
|
38
|
+
config.module ??= {};
|
|
39
|
+
config.module.rules ??= [];
|
|
40
|
+
const use = [];
|
|
41
|
+
if (options.defaultLoaders?.babel) {
|
|
42
|
+
use.push(options.defaultLoaders.babel);
|
|
43
|
+
}
|
|
44
|
+
use.push({ loader: babelLoaderPath() });
|
|
45
|
+
config.module.rules.push({
|
|
46
|
+
test: /\.(tsx|jsx)$/,
|
|
47
|
+
exclude: /node_modules/,
|
|
48
|
+
use,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Defer to the user's own webpack override, if any.
|
|
52
|
+
return typeof nextConfig.webpack === "function"
|
|
53
|
+
? nextConfig.webpack(config, options)
|
|
54
|
+
: config;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/next/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAyBzC,6EAA6E;AAC7E,SAAS,eAAe;IACtB,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,aAA6B,EAAE;IAE/B,oEAAoE;IACpE,wEAAwE;IACxE,mEAAmE;IACnE,0EAA0E;IAC1E,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,eAAe,EAAE,CAAC;QAC9C,eAAe,GAAG,IAAI,CAAC;QACvB,OAAO,CAAC,IAAI,CACV,kEAAkE;YAChE,gEAAgE;YAChE,mEAAmE,CACtE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,GAAG,UAAU;QACb,OAAO,CAAC,MAAyB,EAAE,OAAuB;YACxD,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;gBAChB,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;gBACrB,MAAM,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE,CAAC;gBAC3B,MAAM,GAAG,GAAc,EAAE,CAAC;gBAC1B,IAAI,OAAO,CAAC,cAAc,EAAE,KAAK,EAAE,CAAC;oBAClC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;gBACzC,CAAC;gBACD,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;gBACxC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;oBACvB,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE,cAAc;oBACvB,GAAG;iBACJ,CAAC,CAAC;YACL,CAAC;YACD,oDAAoD;YACpD,OAAO,OAAO,UAAU,CAAC,OAAO,KAAK,UAAU;gBAC7C,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;gBACrC,CAAC,CAAC,MAAM,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface TransformOptions {
|
|
2
|
+
/** Force-enable in production builds (not recommended). Default: false. */
|
|
3
|
+
production?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface TransformResult {
|
|
6
|
+
code: string;
|
|
7
|
+
map: object | null;
|
|
8
|
+
}
|
|
9
|
+
/** Whether attrs should be injected given env + options. */
|
|
10
|
+
export declare function shouldTransform(options?: TransformOptions): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Transform `code` for `filename`, injecting the layout source-location attrs.
|
|
13
|
+
*
|
|
14
|
+
* Returns the original code unchanged (with `map: null`) when transformation
|
|
15
|
+
* is skipped (production env, parse failure). Never throws on user code — a
|
|
16
|
+
* malformed file is passed through untouched so the dev build keeps working.
|
|
17
|
+
*/
|
|
18
|
+
export declare function transformWithLayoutAttrs(code: string, filename: string, projectRoot: string, options?: TransformOptions): TransformResult;
|
|
19
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/plugins/transform.ts"],"names":[],"mappings":"AA+CA,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAGvE;AA0ED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CAyEjB"}
|