@kuznai/inception-engine 0.19.0 → 0.20.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.
Files changed (105) hide show
  1. package/README.md +48 -22
  2. package/dist/{config → src/config}/agents.js +87 -14
  3. package/dist/{core → src/core}/adapters/agent-definitions.d.ts +0 -12
  4. package/dist/src/core/adapters/agent-definitions.js +162 -0
  5. package/dist/{core → src/core}/adapters/frontmatter.d.ts +10 -0
  6. package/dist/{core → src/core}/adapters/frontmatter.js +23 -6
  7. package/dist/{core → src/core}/adapters/mcp.js +17 -20
  8. package/dist/{core → src/core}/adapters/permissions.js +16 -20
  9. package/dist/{core → src/core}/adapters/rules.js +26 -50
  10. package/dist/src/core/capabilities.d.ts +47 -0
  11. package/dist/src/core/capabilities.js +280 -0
  12. package/dist/{core → src/core}/deploy.js +70 -41
  13. package/dist/{core → src/core}/init.js +18 -24
  14. package/dist/src/core/merge-patch.d.ts +4 -0
  15. package/dist/src/core/merge-patch.js +46 -0
  16. package/dist/{core → src/core}/ownership.js +13 -0
  17. package/dist/{core → src/core}/preflight.js +141 -29
  18. package/dist/{core → src/core}/revert.js +86 -26
  19. package/dist/{core → src/core}/validation.js +20 -0
  20. package/dist/{schemas → src/schemas}/manifest.d.ts +20 -0
  21. package/dist/{schemas → src/schemas}/manifest.js +11 -0
  22. package/dist/{schemas → src/schemas}/registry.d.ts +36 -0
  23. package/dist/{schemas → src/schemas}/registry.js +12 -4
  24. package/dist/{types.d.ts → src/types.d.ts} +13 -0
  25. package/dist/test/helpers/fs.d.ts +2 -0
  26. package/dist/test/helpers/fs.js +17 -0
  27. package/dist/test/helpers/path.d.ts +10 -0
  28. package/dist/test/helpers/path.js +15 -0
  29. package/dist/test/helpers/skill-dir-scenarios.d.ts +7 -0
  30. package/dist/test/helpers/skill-dir-scenarios.js +206 -0
  31. package/dist/test/helpers/skill-dir.d.ts +7 -0
  32. package/dist/test/helpers/skill-dir.js +46 -0
  33. package/dist/test/os/cross-platform/cross-platform.test.d.ts +1 -0
  34. package/dist/test/os/cross-platform/cross-platform.test.js +328 -0
  35. package/dist/test/os/posix/skill-dir.test.d.ts +1 -0
  36. package/dist/test/os/posix/skill-dir.test.js +19 -0
  37. package/dist/test/os/windows/revert-integration.test.d.ts +1 -0
  38. package/dist/test/os/windows/revert-integration.test.js +72 -0
  39. package/dist/test/os/windows/skill-dir.test.d.ts +1 -0
  40. package/dist/test/os/windows/skill-dir.test.js +19 -0
  41. package/dist/test/unit/adapters.test.d.ts +1 -0
  42. package/dist/test/unit/adapters.test.js +947 -0
  43. package/dist/test/unit/capabilities.test.d.ts +1 -0
  44. package/dist/test/unit/capabilities.test.js +71 -0
  45. package/dist/test/unit/cli.test.d.ts +1 -0
  46. package/dist/test/unit/cli.test.js +834 -0
  47. package/dist/test/unit/deploy.test.d.ts +1 -0
  48. package/dist/test/unit/deploy.test.js +2481 -0
  49. package/dist/test/unit/detect.test.d.ts +1 -0
  50. package/dist/test/unit/detect.test.js +192 -0
  51. package/dist/test/unit/enterprise.test.d.ts +1 -0
  52. package/dist/test/unit/enterprise.test.js +106 -0
  53. package/dist/test/unit/frontmatter.test.d.ts +1 -0
  54. package/dist/test/unit/frontmatter.test.js +102 -0
  55. package/dist/test/unit/gemini-north-star.test.d.ts +1 -0
  56. package/dist/test/unit/gemini-north-star.test.js +243 -0
  57. package/dist/test/unit/manifest.test.d.ts +1 -0
  58. package/dist/test/unit/manifest.test.js +737 -0
  59. package/dist/test/unit/migration-golden.test.d.ts +1 -0
  60. package/dist/test/unit/migration-golden.test.js +197 -0
  61. package/dist/test/unit/ownership.test.d.ts +1 -0
  62. package/dist/test/unit/ownership.test.js +587 -0
  63. package/dist/test/unit/preflight.test.d.ts +1 -0
  64. package/dist/test/unit/preflight.test.js +501 -0
  65. package/dist/test/unit/resolve.test.d.ts +1 -0
  66. package/dist/test/unit/resolve.test.js +119 -0
  67. package/dist/test/unit/revert.test.d.ts +1 -0
  68. package/dist/test/unit/revert.test.js +1004 -0
  69. package/dist/test/unit/toml.test.d.ts +1 -0
  70. package/dist/test/unit/toml.test.js +55 -0
  71. package/package.json +1 -1
  72. package/dist/core/adapters/agent-definitions.js +0 -91
  73. /package/dist/{config → src/config}/agents.d.ts +0 -0
  74. /package/dist/{config → src/config}/manifest.d.ts +0 -0
  75. /package/dist/{config → src/config}/manifest.js +0 -0
  76. /package/dist/{core → src/core}/adapters/index.d.ts +0 -0
  77. /package/dist/{core → src/core}/adapters/index.js +0 -0
  78. /package/dist/{core → src/core}/adapters/mcp.d.ts +0 -0
  79. /package/dist/{core → src/core}/adapters/permissions.d.ts +0 -0
  80. /package/dist/{core → src/core}/adapters/rules.d.ts +0 -0
  81. /package/dist/{core → src/core}/adapters/toml.d.ts +0 -0
  82. /package/dist/{core → src/core}/adapters/toml.js +0 -0
  83. /package/dist/{core → src/core}/deploy.d.ts +0 -0
  84. /package/dist/{core → src/core}/detect.d.ts +0 -0
  85. /package/dist/{core → src/core}/detect.js +0 -0
  86. /package/dist/{core → src/core}/init.d.ts +0 -0
  87. /package/dist/{core → src/core}/ownership.d.ts +0 -0
  88. /package/dist/{core → src/core}/preflight.d.ts +0 -0
  89. /package/dist/{core → src/core}/resolve.d.ts +0 -0
  90. /package/dist/{core → src/core}/resolve.js +0 -0
  91. /package/dist/{core → src/core}/revert.d.ts +0 -0
  92. /package/dist/{core → src/core}/runtime-paths.d.ts +0 -0
  93. /package/dist/{core → src/core}/runtime-paths.js +0 -0
  94. /package/dist/{core → src/core}/validation.d.ts +0 -0
  95. /package/dist/{errors.d.ts → src/errors.d.ts} +0 -0
  96. /package/dist/{errors.js → src/errors.js} +0 -0
  97. /package/dist/{formatters.d.ts → src/formatters.d.ts} +0 -0
  98. /package/dist/{formatters.js → src/formatters.js} +0 -0
  99. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  100. /package/dist/{index.js → src/index.js} +0 -0
  101. /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
  102. /package/dist/{logger.js → src/logger.js} +0 -0
  103. /package/dist/{schemas → src/schemas}/errors.d.ts +0 -0
  104. /package/dist/{schemas → src/schemas}/errors.js +0 -0
  105. /package/dist/{types.js → src/types.js} +0 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ import assert from "node:assert/strict";
2
+ import fs from "node:fs/promises";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { afterEach, beforeEach, describe, it } from "node:test";
6
+ import { applyTomlMcpPatch, revertTomlMcpPatch, } from "../../src/core/adapters/toml.js";
7
+ describe("TOML Adapter", () => {
8
+ let tmpDir;
9
+ beforeEach(async () => {
10
+ tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "inception-toml-test-"));
11
+ });
12
+ afterEach(async () => {
13
+ await fs.rm(tmpDir, { recursive: true, force: true });
14
+ });
15
+ it("applies an MCP server patch to a new TOML file", async () => {
16
+ const target = path.join(tmpDir, "config.toml");
17
+ const config = { command: "npx", args: ["serve"] };
18
+ await applyTomlMcpPatch(target, "my-skill", config);
19
+ const content = await fs.readFile(target, "utf-8");
20
+ assert.match(content, /\[mcpServers\.my-skill\]/);
21
+ assert.match(content, /command = "npx"/);
22
+ assert.match(content, /args = \[ "serve" \]/);
23
+ });
24
+ it("applies an MCP server patch to an existing TOML file preserving other keys", async () => {
25
+ const target = path.join(tmpDir, "config.toml");
26
+ await fs.writeFile(target, 'title = "My App"\n\n[mcpServers.other]\ncommand = "ls"\n');
27
+ const config = { command: "npx", args: ["serve"] };
28
+ await applyTomlMcpPatch(target, "my-skill", config);
29
+ const content = await fs.readFile(target, "utf-8");
30
+ assert.match(content, /title = "My App"/);
31
+ assert.match(content, /\[mcpServers\.other\]/);
32
+ assert.match(content, /\[mcpServers\.my-skill\]/);
33
+ assert.match(content, /command = "npx"/);
34
+ });
35
+ it("reverts an MCP server patch", async () => {
36
+ const target = path.join(tmpDir, "config.toml");
37
+ await fs.writeFile(target, '[mcpServers.other]\ncommand = "ls"\n\n[mcpServers.my-skill]\ncommand = "npx"\n');
38
+ await revertTomlMcpPatch(target, "my-skill");
39
+ const content = await fs.readFile(target, "utf-8");
40
+ assert.match(content, /\[mcpServers\.other\]/);
41
+ assert.doesNotMatch(content, /my-skill/);
42
+ });
43
+ it("cleans up [mcpServers] table if it becomes empty after revert", async () => {
44
+ const target = path.join(tmpDir, "config.toml");
45
+ await fs.writeFile(target, '[mcpServers.my-skill]\ncommand = "npx"\n');
46
+ await revertTomlMcpPatch(target, "my-skill");
47
+ const content = await fs.readFile(target, "utf-8");
48
+ assert.strictEqual(content.trim(), "");
49
+ });
50
+ it("throws error if config.toml is invalid TOML", async () => {
51
+ const target = path.join(tmpDir, "config.toml");
52
+ await fs.writeFile(target, 'this is not = toml "bad"');
53
+ await assert.rejects(() => applyTomlMcpPatch(target, "any", {}), /Invalid TOML document/);
54
+ });
55
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kuznai/inception-engine",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Deploy AI agent skills from a git repo to user home directories",
5
5
  "license": "MIT",
6
6
  "author": "Damian Piątkowski",
@@ -1,91 +0,0 @@
1
- import path from "node:path";
2
- import { AGENT_REGISTRY_BY_ID } from "../../config/agents.js";
3
- import { getPlatformKey, resolvePlaceholders } from "../resolve.js";
4
- import { validateAgentRuleMarkdownPath, validateInstructionFileRequirements, validateSourceFile, validateSourcePath, } from "../validation.js";
5
- /**
6
- * Compiles deploy actions for agentDefinitions manifest entries.
7
- *
8
- * Agent definition files are Markdown files (typically with YAML frontmatter)
9
- * that define custom agents or subagents for a given platform. Unlike
10
- * agentRules (which target a single shared global file per agent), each
11
- * definition entry produces a separate file named after the entry in the
12
- * agent's dedicated agent-definitions directory (repo-local).
13
- *
14
- * Target paths use the `{repo}` placeholder so definitions land in the
15
- * repository being deployed, not the user's home directory.
16
- */
17
- export async function compileAgentDefinitionActions(entry, sourceDir, resolvedSourceDir, realRoot, detectedAgents, home, repo, workspace) {
18
- const actions = [];
19
- const warnings = [];
20
- const platform = getPlatformKey();
21
- const targetAgents = entry.agents.filter((agentId) => detectedAgents.includes(agentId));
22
- const supportedTargets = [];
23
- if (targetAgents.length === 0) {
24
- return { actions, warnings };
25
- }
26
- for (const agentId of targetAgents) {
27
- const agent = AGENT_REGISTRY_BY_ID[agentId];
28
- const support = agent?.agentDefinitionsSupport;
29
- if (!support || support.status === "unsupported") {
30
- warnings.push({
31
- kind: "confidence",
32
- message: `agentDefinitions: agent "${agentId}" uses ${support?.schemaLabel ?? "an unsupported agent-definition schema"} and ${support?.status === "unsupported" ? support.reason : "does not expose a supported agent-definitions adapter"} — skipping "${entry.name}"`,
33
- });
34
- continue;
35
- }
36
- if (support.status === "planned") {
37
- warnings.push({
38
- kind: "confidence",
39
- message: `agentDefinitions: agent "${agentId}" agent-definitions support is planned via ${support.plannedSurface} — skipping "${entry.name}" until that surface is implemented`,
40
- });
41
- continue;
42
- }
43
- supportedTargets.push({
44
- agentId,
45
- confidence: agent.provenance.agentDefinitions ?? "provisional",
46
- target: resolvePlaceholders(support.path[platform], entry.name, home, repo, workspace),
47
- });
48
- }
49
- if (supportedTargets.length === 0) {
50
- return { actions, warnings };
51
- }
52
- // Validate the shared source file only when at least one target is active.
53
- const source = path.resolve(sourceDir, entry.path);
54
- await validateSourcePath(source, entry.path, resolvedSourceDir, realRoot);
55
- await validateSourceFile(source, entry.path);
56
- for (const target of supportedTargets) {
57
- validateAgentRuleMarkdownPath(entry.path, target.agentId);
58
- await validateInstructionFileRequirements(source, entry.path, target.agentId);
59
- actions.push({
60
- kind: "file-write",
61
- skill: entry.name,
62
- agent: target.agentId,
63
- source,
64
- target: target.target,
65
- confidence: target.confidence,
66
- });
67
- }
68
- return { actions, warnings };
69
- }
70
- export function compileAgentDefinitionReverts(entry, agentFilter, home, repo, workspace) {
71
- const actions = [];
72
- const platform = getPlatformKey();
73
- for (const agentId of entry.agents) {
74
- if (agentFilter && !agentFilter.includes(agentId))
75
- continue;
76
- const agent = AGENT_REGISTRY_BY_ID[agentId];
77
- const support = agent?.agentDefinitionsSupport;
78
- if (!support ||
79
- support.status === "unsupported" ||
80
- support.status === "planned")
81
- continue;
82
- const target = resolvePlaceholders(support.path[platform], entry.name, home, repo, workspace);
83
- actions.push({
84
- kind: "file-write",
85
- skill: entry.name,
86
- agent: agentId,
87
- target,
88
- });
89
- }
90
- return actions;
91
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes