@kuznai/inception-engine 0.23.0 → 0.24.0

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.
@@ -1,245 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
3
- import path from "node:path";
4
- import { describe, it } from "node:test";
5
- import { executeDeploy } from "../../../src/core/deploy.js";
6
- import { lookupDeployment, registerDeployment, } from "../../../src/core/ownership.js";
7
- import { executeRevert } from "../../../src/core/revert.js";
8
- import { exists, makeTmpDir } from "../../helpers/fs.js";
9
- describe("agentRules repo/workspace file-write (Windows)", {
10
- skip: process.platform !== "win32",
11
- }, () => {
12
- it("deploys agentRules with scope repo and registers it", async () => {
13
- const home = await makeTmpDir("ie-rules-home");
14
- const repo = await makeTmpDir("ie-rules-repo");
15
- const sourceDir = await makeTmpDir("ie-rules-source");
16
- try {
17
- const source = path.join(sourceDir, "CLAUDE.md");
18
- await writeFile(source, "# My Rules\n");
19
- const target = path.join(repo, "CLAUDE.md");
20
- const action = {
21
- kind: "file-write",
22
- skill: "my-rules",
23
- agent: "claude-code",
24
- source,
25
- target,
26
- };
27
- const { succeeded, failed } = await executeDeploy([action], false, false, home);
28
- assert.equal(succeeded, 1);
29
- assert.equal(failed.length, 0);
30
- assert.ok(await exists(target));
31
- const entry = await lookupDeployment(home, target);
32
- assert.ok(entry !== null);
33
- assert.equal(entry?.kind, "file-write");
34
- }
35
- finally {
36
- await rm(home, { recursive: true, force: true });
37
- await rm(repo, { recursive: true, force: true });
38
- await rm(sourceDir, { recursive: true, force: true });
39
- }
40
- });
41
- it("reverts agentRules with scope repo and unregisters it", async () => {
42
- const home = await makeTmpDir("ie-rules-home");
43
- const repo = await makeTmpDir("ie-rules-repo");
44
- try {
45
- const source = path.join(repo, "source-CLAUDE.md");
46
- const target = path.join(repo, "CLAUDE.md");
47
- await writeFile(target, "# My Rules\n");
48
- await registerDeployment(home, target, {
49
- kind: "file-write",
50
- source,
51
- skill: "my-rules",
52
- agent: "claude-code",
53
- });
54
- const action = {
55
- kind: "file-write",
56
- skill: "my-rules",
57
- agent: "claude-code",
58
- target,
59
- };
60
- const { succeeded, failed } = await executeRevert([action], false, false, home);
61
- assert.equal(succeeded, 1);
62
- assert.equal(failed.length, 0);
63
- assert.ok(!(await exists(target)));
64
- assert.equal(await lookupDeployment(home, target), null);
65
- }
66
- finally {
67
- await rm(home, { recursive: true, force: true });
68
- await rm(repo, { recursive: true, force: true });
69
- }
70
- });
71
- it("deploys agentRules with scope workspace and registers it", async () => {
72
- const home = await makeTmpDir("ie-rules-home");
73
- const workspace = await makeTmpDir("ie-rules-workspace");
74
- const sourceDir = await makeTmpDir("ie-rules-source");
75
- try {
76
- const source = path.join(sourceDir, "CLAUDE.md");
77
- await writeFile(source, "# Workspace Rules\n");
78
- const target = path.join(workspace, "CLAUDE.md");
79
- const action = {
80
- kind: "file-write",
81
- skill: "my-rules",
82
- agent: "claude-code",
83
- source,
84
- target,
85
- };
86
- const { succeeded, failed } = await executeDeploy([action], false, false, home);
87
- assert.equal(succeeded, 1);
88
- assert.equal(failed.length, 0);
89
- assert.ok(await exists(target));
90
- const entry = await lookupDeployment(home, target);
91
- assert.ok(entry !== null);
92
- assert.equal(entry?.kind, "file-write");
93
- }
94
- finally {
95
- await rm(home, { recursive: true, force: true });
96
- await rm(workspace, { recursive: true, force: true });
97
- await rm(sourceDir, { recursive: true, force: true });
98
- }
99
- });
100
- it("reverts agentRules with scope workspace and unregisters it", async () => {
101
- const home = await makeTmpDir("ie-rules-home");
102
- const workspace = await makeTmpDir("ie-rules-workspace");
103
- try {
104
- const source = path.join(workspace, "source-CLAUDE.md");
105
- const target = path.join(workspace, "CLAUDE.md");
106
- await writeFile(target, "# Workspace Rules\n");
107
- await registerDeployment(home, target, {
108
- kind: "file-write",
109
- source,
110
- skill: "my-rules",
111
- agent: "claude-code",
112
- });
113
- const action = {
114
- kind: "file-write",
115
- skill: "my-rules",
116
- agent: "claude-code",
117
- target,
118
- };
119
- const { succeeded, failed } = await executeRevert([action], false, false, home);
120
- assert.equal(succeeded, 1);
121
- assert.equal(failed.length, 0);
122
- assert.ok(!(await exists(target)));
123
- assert.equal(await lookupDeployment(home, target), null);
124
- }
125
- finally {
126
- await rm(home, { recursive: true, force: true });
127
- await rm(workspace, { recursive: true, force: true });
128
- }
129
- });
130
- });
131
- describe("Antigravity frontmatter-emit (Windows)", {
132
- skip: process.platform !== "win32",
133
- }, () => {
134
- it("deploys frontmatter-emit for Antigravity and registers it", async () => {
135
- const home = await makeTmpDir("ie-fm-home");
136
- const repo = await makeTmpDir("ie-fm-repo");
137
- try {
138
- const target = path.join(repo, ".agents", "rules", "my-mcp.md");
139
- const frontmatter = {
140
- "mcp-servers": {
141
- "my-mcp": { command: "npx", args: ["-y", "my-mcp-server"] },
142
- },
143
- };
144
- const action = {
145
- kind: "frontmatter-emit",
146
- skill: "my-mcp",
147
- agent: "antigravity",
148
- target,
149
- frontmatter,
150
- };
151
- const { succeeded, failed } = await executeDeploy([action], false, false, home);
152
- assert.equal(succeeded, 1);
153
- assert.equal(failed.length, 0);
154
- assert.ok(await exists(target));
155
- const content = await readFile(target, "utf-8");
156
- assert.ok(content.includes("mcp-servers:"));
157
- const entry = await lookupDeployment(home, target);
158
- assert.ok(entry !== null);
159
- assert.equal(entry?.kind, "frontmatter-emit");
160
- assert.equal(entry.created, true);
161
- }
162
- finally {
163
- await rm(home, { recursive: true, force: true });
164
- await rm(repo, { recursive: true, force: true });
165
- }
166
- });
167
- it("reverts frontmatter-emit for Antigravity and removes file when no body", async () => {
168
- const home = await makeTmpDir("ie-fm-home");
169
- const repo = await makeTmpDir("ie-fm-repo");
170
- try {
171
- const target = path.join(repo, ".agents", "rules", "my-mcp.md");
172
- const frontmatter = {
173
- "mcp-servers": {
174
- "my-mcp": { command: "npx", args: ["-y", "my-mcp-server"] },
175
- },
176
- };
177
- // Deploy first so the file and registry entry are created.
178
- const deployAction = {
179
- kind: "frontmatter-emit",
180
- skill: "my-mcp",
181
- agent: "antigravity",
182
- target,
183
- frontmatter,
184
- };
185
- await executeDeploy([deployAction], false, false, home);
186
- const action = {
187
- kind: "frontmatter-emit",
188
- skill: "my-mcp",
189
- agent: "antigravity",
190
- target,
191
- };
192
- const { succeeded, failed } = await executeRevert([action], false, false, home);
193
- assert.equal(succeeded, 1);
194
- assert.equal(failed.length, 0);
195
- assert.ok(!(await exists(target)));
196
- assert.equal(await lookupDeployment(home, target), null);
197
- }
198
- finally {
199
- await rm(home, { recursive: true, force: true });
200
- await rm(repo, { recursive: true, force: true });
201
- }
202
- });
203
- it("reverts frontmatter-emit for Antigravity preserving body when file had prior content", async () => {
204
- const home = await makeTmpDir("ie-fm-home");
205
- const repo = await makeTmpDir("ie-fm-repo");
206
- try {
207
- const target = path.join(repo, ".agents", "rules", "my-mcp.md");
208
- await mkdir(path.dirname(target), { recursive: true });
209
- await writeFile(target, "# My Rules\n");
210
- const undoPatch = { "mcp-servers": null };
211
- await registerDeployment(home, target, {
212
- kind: "frontmatter-emit",
213
- patch: {
214
- "mcp-servers": {
215
- "my-mcp": { command: "npx", args: ["-y", "my-mcp-server"] },
216
- },
217
- },
218
- undoPatch,
219
- created: false,
220
- hadFrontmatter: false,
221
- skill: "my-mcp",
222
- agent: "antigravity",
223
- });
224
- const action = {
225
- kind: "frontmatter-emit",
226
- skill: "my-mcp",
227
- agent: "antigravity",
228
- target,
229
- };
230
- const { succeeded, failed } = await executeRevert([action], false, false, home);
231
- assert.equal(succeeded, 1);
232
- assert.equal(failed.length, 0);
233
- // File should still exist because it had body content.
234
- assert.ok(await exists(target));
235
- const content = await readFile(target, "utf-8");
236
- assert.ok(!content.includes("mcp-servers:"));
237
- assert.ok(content.includes("My Rules"));
238
- assert.equal(await lookupDeployment(home, target), null);
239
- }
240
- finally {
241
- await rm(home, { recursive: true, force: true });
242
- await rm(repo, { recursive: true, force: true });
243
- }
244
- });
245
- });
@@ -1,72 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
3
- import path from "node:path";
4
- import { describe, it } from "node:test";
5
- import { lookupDeployment, registerDeployment, } from "../../../src/core/ownership.js";
6
- import { executeRevert } from "../../../src/core/revert.js";
7
- import { exists, makeTmpDir } from "../../helpers/fs.js";
8
- describe("revert integration (Windows)", {
9
- skip: process.platform !== "win32",
10
- }, () => {
11
- it("reverts a deployed mcpServer config-patch and unregisters it", async () => {
12
- const home = await makeTmpDir("ie-revert-home");
13
- try {
14
- const configFile = path.join(home, ".claude.json");
15
- await writeFile(configFile, JSON.stringify({
16
- other: "value",
17
- mcpServers: { "my-mcp": { command: "npx" } },
18
- }));
19
- await registerDeployment(home, configFile, {
20
- kind: "config-patch",
21
- patch: { mcpServers: { "my-mcp": { command: "npx" } } },
22
- undoPatch: { mcpServers: null },
23
- skill: "my-mcp",
24
- agent: "claude-code",
25
- });
26
- const action = {
27
- kind: "config-patch",
28
- skill: "my-mcp",
29
- agent: "claude-code",
30
- target: configFile,
31
- };
32
- const { succeeded, failed } = await executeRevert([action], false, false, home);
33
- assert.equal(succeeded, 1);
34
- assert.equal(failed.length, 0);
35
- assert.deepEqual(JSON.parse(await readFile(configFile, "utf-8")), {
36
- other: "value",
37
- });
38
- assert.equal(await lookupDeployment(home, configFile), null);
39
- }
40
- finally {
41
- await rm(home, { recursive: true, force: true });
42
- }
43
- });
44
- it("reverts a deployed agentRule file-write and unregisters it", async () => {
45
- const home = await makeTmpDir("ie-revert-home");
46
- try {
47
- const rulesFile = path.join(home, ".claude", "CLAUDE.md");
48
- await mkdir(path.dirname(rulesFile), { recursive: true });
49
- await writeFile(rulesFile, "# My Rules\n");
50
- await registerDeployment(home, rulesFile, {
51
- kind: "file-write",
52
- source: "/some/source/CLAUDE.md",
53
- skill: "my-rules",
54
- agent: "claude-code",
55
- });
56
- const action = {
57
- kind: "file-write",
58
- skill: "my-rules",
59
- agent: "claude-code",
60
- target: rulesFile,
61
- };
62
- const { succeeded, failed } = await executeRevert([action], false, false, home);
63
- assert.equal(succeeded, 1);
64
- assert.equal(failed.length, 0);
65
- assert.ok(!(await exists(rulesFile)));
66
- assert.equal(await lookupDeployment(home, rulesFile), null);
67
- }
68
- finally {
69
- await rm(home, { recursive: true, force: true });
70
- }
71
- });
72
- });