@n8n-as-code/n8nac 2.1.3 → 2.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @n8n-as-code/n8nac
2
2
 
3
+ ## [2.1.4](https://github.com/EtienneLescot/n8n-as-code/compare/@n8n-as-code/n8nac@v2.1.3...@n8n-as-code/n8nac@v2.1.4) (2026-06-05)
4
+
5
+ ### Bug Fixes
6
+
7
+ * address v4 workspace review feedback ([d111a7f](https://github.com/EtienneLescot/n8n-as-code/commit/d111a7fcc31cbdc2a3309cf4979395ee8f179880))
8
+ * require v4 workspace environments ([6967d4d](https://github.com/EtienneLescot/n8n-as-code/commit/6967d4d0ecbaa4d18fe0077f42531b215f574d5e))
9
+
3
10
  ## [2.1.3](https://github.com/EtienneLescot/n8n-as-code/compare/@n8n-as-code/n8nac@v2.1.2...@n8n-as-code/n8nac@v2.1.3) (2026-05-21)
4
11
 
5
12
  ### Dependencies
package/index.ts CHANGED
@@ -26,9 +26,10 @@ Supported facade runtime modes:
26
26
  ${SETUP_MODE_CONTEXT}
27
27
 
28
28
  For agent-driven flows, use the installed \`n8n-manager\` and \`n8n-architect\`
29
- skills and their documented shell commands. Instance/auth/project management
30
- belongs to \`n8n-manager\`; context-root overrides and workflow sync belong
31
- to \`n8nac workspace\` and the n8n-as-code skills.
29
+ skills and their documented shell commands. Local managed runtime lifecycle
30
+ belongs to \`n8n-manager\`; environment/project/auth/workflowsPath management
31
+ uses V4 \`n8nac env\` commands such as \`env add\`, \`env update\`, and
32
+ \`env auth set\`, and workflow sync uses the n8n-as-code skills.
32
33
  `;
33
34
 
34
35
  function buildStatusHeader(workspaceDir: string): string {
@@ -39,13 +40,13 @@ function buildStatusHeader(workspaceDir: string): string {
39
40
  "**The context root is initialized. Do NOT infer effective n8n config from this prompt.**",
40
41
  "",
41
42
  `- Context root: \`${workspaceDir}\``,
42
- `- Local overrides file: \`${join(workspaceDir, "n8nac-config.json")}\``,
43
+ `- Workspace environment file: \`${join(workspaceDir, "n8nac-config.json")}\``,
43
44
  `- Bootstrap file: \`${join(workspaceDir, "AGENTS.md")}\``,
44
45
  "",
45
- "Before n8n work, run `n8nac workspace status --json` from the context root and use the backend-resolved result.",
46
- cfg.activeInstanceId || cfg.projectId || cfg.projectName || cfg.syncFolder
47
- ? "The local overrides file exists, but n8n-manager plus n8nac backend resolution remains the only source of effective state."
48
- : "The local overrides file is present but incomplete.",
46
+ "Before n8n work, run `n8nac env status --json` from the context root and use the backend-resolved result.",
47
+ cfg.environmentId || cfg.workflowsPath
48
+ ? "The workspace environment file exists, but n8nac backend resolution remains the only source of effective state."
49
+ : "The workspace environment file is present but incomplete.",
49
50
  ].join("\n");
50
51
  }
51
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8n-as-code/n8nac",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "OpenClaw plugin for n8n-as-code — create and manage n8n workflows from OpenClaw",
5
5
  "keywords": [
6
6
  "n8n",
@@ -5,7 +5,7 @@ description: Use when the user explicitly wants to create, edit, validate, sync,
5
5
 
6
6
  # n8n Architect
7
7
 
8
- Use this skill for all n8n-as-code work: workspace readiness, migration, environments, managed local instances, tunnels, workflow authoring, validation, sync, push, and pull.
8
+ Use this skill for all n8n-as-code work: workspace readiness, environments, managed local instances, tunnels, workflow authoring, validation, sync, push, and pull.
9
9
 
10
10
  Use `npx --yes n8nac` as the primary interface. Use `npx --yes @n8n-as-code/n8n-manager` only for local managed runtime lifecycle, tunnels, and workflow presentation commands that are explicitly exposed by n8n-manager.
11
11
 
@@ -30,41 +30,15 @@ npx --yes n8nac env status --json
30
30
 
31
31
  ## Workspace Readiness
32
32
 
33
- Use the unified migration preflight before resolving the effective environment. The dry-run is safe and reports whether any workspace migration is required:
33
+ Resolve the effective environment through the backend before workflow work:
34
34
 
35
35
  ```bash
36
- npx --yes n8nac workspace migrate --json
37
36
  npx --yes n8nac env status --json
38
37
  ```
39
38
 
40
- - Treat `workspace migrate --json` as the source of migration need.
41
- - Treat `env status --json` as the source of effective workspace readiness only after migration is not required or has been applied.
39
+ - Treat `env status --json` as the source of effective workspace readiness.
42
40
  - Do not infer readiness from raw files, generated agent docs, or directory names.
43
- - If migration is required, do not edit config files by hand or continue with environment/workflow work until it has been applied or explicitly deferred by the user.
44
-
45
- ## Migration
46
-
47
- Migration is one user-facing command. Do not reason about internal migration phases directly; summarize the report `operations` array when explaining what will change.
48
-
49
- 1. Run the dry-run first:
50
-
51
- ```bash
52
- npx --yes n8nac workspace migrate --json
53
- ```
54
-
55
- 2. If the dry-run reports `status: "dry-run"`, `required: true`, or otherwise indicates pending changes, stop and ask once before applying it. Do not run `workspace migrate --write` unless the user already directly requested applying migration.
56
- 3. After confirmation, apply migration and re-check readiness:
57
-
58
- ```bash
59
- npx --yes n8nac workspace migrate --write
60
- npx --yes n8nac workspace migrate --json
61
- npx --yes n8nac env status --json
62
- ```
63
-
64
- - Do not run `workspace migrate --write` without explicit confirmation unless the user already directly requested applying migration.
65
- - When reporting a dry-run, summarize the unified `operations` list and ask for exactly one confirmation for `npx --yes n8nac workspace migrate --write`.
66
- - Do not ask separately for different operation types. `npx --yes n8nac workspace migrate --write` applies the required migration as one operation.
67
- - Do not run environment, workflow, or setup commands while `workspace migrate --json` still reports migration required.
41
+ - If `env status --json` fails because the workspace is not configured, use `env add`, `env auth set`, and `env use` to create or select a V4 workspace environment.
68
42
  - Managed local instances remain machine-global runtime resources.
69
43
  - Workspace environments remain workspace-scoped and are managed through `npx --yes n8nac env ...`.
70
44
 
@@ -72,14 +46,12 @@ npx --yes n8nac env status --json
72
46
 
73
47
  1. `cd` to the context root.
74
48
  2. Run `npx --yes n8nac update-ai`, then read `AGENTS.md`.
75
- 3. Run `npx --yes n8nac workspace migrate --json`.
76
- 4. If migration is required, stop and ask for confirmation before `npx --yes n8nac workspace migrate --write` unless the user already requested applying migration.
77
- 5. Run `npx --yes n8nac env status --json` after migration is not required or has been applied.
78
- 6. If the context root is not ready, inspect managed local instances with `npx --yes @n8n-as-code/n8n-manager instance list`.
79
- 7. Reuse an existing environment or managed local instance when suitable.
80
- 8. If no suitable environment exists, stop and ask the user whether they want to connect a remote n8n URL or create/reuse a managed local n8n instance. Do not create infrastructure by default. If the user chooses a managed local instance, ask separately whether they want a public tunnel.
81
- 9. Ask for host/API key only for an explicitly remote n8n environment.
82
- 10. Configure the environment with:
49
+ 3. Run `npx --yes n8nac env status --json`.
50
+ 4. If the context root is not ready, inspect managed local instances with `npx --yes @n8n-as-code/n8n-manager instance list`.
51
+ 5. Reuse an existing environment or managed local instance when suitable.
52
+ 6. If no suitable environment exists, stop and ask the user whether they want to connect a remote n8n URL or create/reuse a managed local n8n instance. Do not create infrastructure by default. If the user chooses a managed local instance, ask separately whether they want a public tunnel.
53
+ 7. Ask for host/API key only for an explicitly remote n8n environment.
54
+ 8. Configure the environment with:
83
55
 
84
56
  ```bash
85
57
  npx --yes n8nac env add <name> --base-url <url> --workflows-path workflows/<name>
@@ -94,7 +66,7 @@ npx --yes n8nac env add Local --managed-instance <id> --workflows-path workflows
94
66
  npx --yes n8nac env use Local
95
67
  ```
96
68
 
97
- 11. Run `npx --yes n8nac update-ai` after changing environments when the facade does not do it automatically.
69
+ 9. Run `npx --yes n8nac update-ai` after changing environments when the facade does not do it automatically.
98
70
 
99
71
  ## Environments
100
72
 
package/src/workspace.ts CHANGED
@@ -3,16 +3,18 @@ import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
 
5
5
  export type WorkspaceBinding = {
6
+ activeEnvironmentId?: string;
7
+ environmentId?: string;
8
+ environmentName?: string;
9
+ workflowsPath?: string;
6
10
  projectId?: string;
7
11
  projectName?: string;
8
- syncFolder?: string;
9
- activeInstanceId?: string;
10
12
  };
11
13
 
12
14
  /**
13
- * Fixed context-root directory for V1.
15
+ * Fixed context-root directory for n8n-as-code.
14
16
  * All n8nac context files (n8nac-config.json, AGENTS.md, .agents/skills, workflows/) live here.
15
- * n8n instances and credentials are stored globally by n8n-manager.
17
+ * Runtime access is resolved through V4 workspace environments.
16
18
  */
17
19
  export function getWorkspaceDir(): string {
18
20
  return join(homedir(), ".openclaw", "n8nac");
@@ -31,12 +33,21 @@ export function readWorkspaceBinding(workspaceDir: string): WorkspaceBinding {
31
33
  try {
32
34
  const raw = readFileSync(configPath, "utf-8");
33
35
  const config = JSON.parse(raw) as Record<string, unknown>;
36
+ if (config.version !== 4) return {};
37
+ const environments = Array.isArray(config.environments) ? config.environments as Array<Record<string, unknown>> : [];
38
+ const activeEnvironmentId = readString(config.activeEnvironmentId);
39
+ const environment = activeEnvironmentId
40
+ ? environments.find((item) => readString(item.id) === activeEnvironmentId)
41
+ : environments[0];
42
+ if (!environment) return { activeEnvironmentId: activeEnvironmentId || undefined };
34
43
 
35
44
  return {
36
- projectId: readString(config.projectId) || undefined,
37
- projectName: readString(config.projectName) || undefined,
38
- syncFolder: readString(config.syncFolder) || undefined,
39
- activeInstanceId: readString(config.activeInstanceId) || undefined,
45
+ activeEnvironmentId: activeEnvironmentId || undefined,
46
+ environmentId: readString(environment.id) || undefined,
47
+ environmentName: readString(environment.name) || undefined,
48
+ workflowsPath: readString(environment.workflowsPath) || undefined,
49
+ projectId: readString(environment.projectId) || undefined,
50
+ projectName: readString(environment.projectName) || undefined,
40
51
  };
41
52
  } catch {
42
53
  return {};
@@ -45,9 +56,9 @@ export function readWorkspaceBinding(workspaceDir: string): WorkspaceBinding {
45
56
 
46
57
  /**
47
58
  * Returns true when n8nac has been initialized in the given directory,
48
- * meaning the config exists and contains a selected project + sync folder.
59
+ * meaning the config exists and contains an active V4 environment with workflowsPath.
49
60
  */
50
61
  export function isWorkspaceInitialized(workspaceDir: string): boolean {
51
62
  const binding = readWorkspaceBinding(workspaceDir);
52
- return Boolean(binding.projectId && binding.projectName && binding.syncFolder);
63
+ return Boolean(binding.environmentId && binding.workflowsPath);
53
64
  }