@n8n-as-code/agent-cli 0.2.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.
- package/README.md +52 -0
- package/dist/assets/n8n-nodes-index.json +505297 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +82 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/services/ai-context-generator.d.ts +11 -0
- package/dist/services/ai-context-generator.d.ts.map +1 -0
- package/dist/services/ai-context-generator.js +101 -0
- package/dist/services/ai-context-generator.js.map +1 -0
- package/dist/services/node-schema-provider.d.ts +27 -0
- package/dist/services/node-schema-provider.d.ts.map +1 -0
- package/dist/services/node-schema-provider.js +92 -0
- package/dist/services/node-schema-provider.js.map +1 -0
- package/dist/services/snippet-generator.d.ts +7 -0
- package/dist/services/snippet-generator.d.ts.map +1 -0
- package/dist/services/snippet-generator.js +141 -0
- package/dist/services/snippet-generator.js.map +1 -0
- package/package.json +36 -0
- package/src/assets/n8n-nodes-index.json +505297 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { NodeSchemaProvider } from './services/node-schema-provider.js';
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
import { join, dirname } from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
// Resolve __dirname for ESM and CJS (bundled)
|
|
9
|
+
const _filename = typeof import.meta !== 'undefined' && import.meta.url
|
|
10
|
+
? fileURLToPath(import.meta.url)
|
|
11
|
+
: (typeof __filename !== 'undefined' ? __filename : '');
|
|
12
|
+
const _dirname = typeof __dirname !== 'undefined'
|
|
13
|
+
? __dirname
|
|
14
|
+
: dirname(_filename);
|
|
15
|
+
const getVersion = () => {
|
|
16
|
+
try {
|
|
17
|
+
const pkgPath = join(_dirname, '../package.json');
|
|
18
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
19
|
+
return pkg.version;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return '0.1.0';
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const program = new Command();
|
|
26
|
+
const provider = new NodeSchemaProvider();
|
|
27
|
+
program
|
|
28
|
+
.name('n8n-agent')
|
|
29
|
+
.description('AI Agent Tools for accessing n8n documentation')
|
|
30
|
+
.version(getVersion());
|
|
31
|
+
// 1. Search
|
|
32
|
+
program
|
|
33
|
+
.command('search')
|
|
34
|
+
.description('Fuzzy search for nodes')
|
|
35
|
+
.argument('<query>', 'Search term (e.g. "google sheets")')
|
|
36
|
+
.action((query) => {
|
|
37
|
+
try {
|
|
38
|
+
const results = provider.searchNodes(query);
|
|
39
|
+
console.log(JSON.stringify(results, null, 2));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error(chalk.red(error.message));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
// 2. Get Schema
|
|
47
|
+
program
|
|
48
|
+
.command('get')
|
|
49
|
+
.description('Get full JSON schema for a specific node')
|
|
50
|
+
.argument('<name>', 'Node name (camelCase, e.g. httpRequest)')
|
|
51
|
+
.action((name) => {
|
|
52
|
+
try {
|
|
53
|
+
const schema = provider.getNodeSchema(name);
|
|
54
|
+
if (schema) {
|
|
55
|
+
console.log(JSON.stringify(schema, null, 2));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.error(chalk.red(`Node '${name}' not found.`));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error(chalk.red(error.message));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// 3. List All
|
|
68
|
+
program
|
|
69
|
+
.command('list')
|
|
70
|
+
.description('List all available nodes (compact)')
|
|
71
|
+
.action(() => {
|
|
72
|
+
try {
|
|
73
|
+
const list = provider.listAllNodes();
|
|
74
|
+
console.log(JSON.stringify(list, null, 2));
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error(chalk.red(error.message));
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
program.parse(process.argv);
|
|
82
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,8CAA8C;AAC9C,MAAM,SAAS,GAAG,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG;IACnE,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IAChC,CAAC,CAAC,CAAC,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE5D,MAAM,QAAQ,GAAG,OAAO,SAAS,KAAK,WAAW;I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AC;AACL,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Library Exports for Consumers
|
|
2
|
+
export { NodeSchemaProvider } from './services/node-schema-provider.js';
|
|
3
|
+
export { AiContextGenerator } from './services/ai-context-generator.js';
|
|
4
|
+
export { SnippetGenerator } from './services/snippet-generator.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class AiContextGenerator {
|
|
2
|
+
constructor();
|
|
3
|
+
generate(projectRoot: string, n8nVersion?: string): Promise<void>;
|
|
4
|
+
private injectOrUpdate;
|
|
5
|
+
private getAgentsContent;
|
|
6
|
+
private getCursorRulesContent;
|
|
7
|
+
private getClineRulesContent;
|
|
8
|
+
private getWindsurfRulesContent;
|
|
9
|
+
private getCommonRulesContent;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ai-context-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-context-generator.d.ts","sourceRoot":"","sources":["../../src/services/ai-context-generator.ts"],"names":[],"mappings":"AAGA,qBAAa,kBAAkB;;IAGvB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,GAAE,MAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBlF,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,qBAAqB;CAQ9B"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export class AiContextGenerator {
|
|
4
|
+
constructor() { }
|
|
5
|
+
async generate(projectRoot, n8nVersion = "Unknown") {
|
|
6
|
+
const agentsContent = this.getAgentsContent(n8nVersion);
|
|
7
|
+
const cursorContent = this.getCursorRulesContent();
|
|
8
|
+
const clineContent = this.getClineRulesContent();
|
|
9
|
+
const windsurfContent = this.getWindsurfRulesContent();
|
|
10
|
+
const commonRules = this.getCommonRulesContent();
|
|
11
|
+
// 1. AGENTS.md (Central documentation)
|
|
12
|
+
this.injectOrUpdate(path.join(projectRoot, 'AGENTS.md'), agentsContent, true);
|
|
13
|
+
// 2. Specialized Rule Files
|
|
14
|
+
this.injectOrUpdate(path.join(projectRoot, '.cursorrules'), cursorContent);
|
|
15
|
+
this.injectOrUpdate(path.join(projectRoot, '.clinerules'), clineContent);
|
|
16
|
+
this.injectOrUpdate(path.join(projectRoot, '.windsurfrules'), windsurfContent);
|
|
17
|
+
// 3. General AI Context (for Claude, Mistral, etc.)
|
|
18
|
+
this.injectOrUpdate(path.join(projectRoot, '.ai-rules.md'), commonRules);
|
|
19
|
+
}
|
|
20
|
+
injectOrUpdate(filePath, content, isMarkdownFile = false) {
|
|
21
|
+
const startMarker = isMarkdownFile ? '<!-- n8n-as-code-start -->' : '### 🤖 n8n-as-code-start';
|
|
22
|
+
const endMarker = isMarkdownFile ? '<!-- n8n-as-code-end -->' : '### 🤖 n8n-as-code-end';
|
|
23
|
+
const block = `\n${startMarker}\n${content.trim()}\n${endMarker}\n`;
|
|
24
|
+
if (!fs.existsSync(filePath)) {
|
|
25
|
+
// Create new file with header if it's AGENTS.md
|
|
26
|
+
const header = filePath.endsWith('AGENTS.md') ? '# 🤖 AI Agents Guidelines\n' : '';
|
|
27
|
+
fs.writeFileSync(filePath, header + block.trim() + '\n');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let existing = fs.readFileSync(filePath, 'utf8');
|
|
31
|
+
const startIdx = existing.indexOf(startMarker);
|
|
32
|
+
const endIdx = existing.indexOf(endMarker);
|
|
33
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
34
|
+
// Update existing block while preserving what's before/after
|
|
35
|
+
const before = existing.substring(0, startIdx);
|
|
36
|
+
const after = existing.substring(endIdx + endMarker.length);
|
|
37
|
+
fs.writeFileSync(filePath, before + block.trim() + after);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// Append to end of existing file
|
|
41
|
+
fs.writeFileSync(filePath, existing.trim() + '\n' + block);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
getAgentsContent(n8nVersion) {
|
|
45
|
+
return [
|
|
46
|
+
`## 🎭 Role: Expert n8n Engineer`,
|
|
47
|
+
`You manage n8n workflows as **clean, version-controlled JSON**.`,
|
|
48
|
+
``,
|
|
49
|
+
`### 🌍 Context`,
|
|
50
|
+
`- **n8n Version**: ${n8nVersion}`,
|
|
51
|
+
`- **Schema**: Use \`n8n-schema.json\` for structural validation.`,
|
|
52
|
+
``,
|
|
53
|
+
`### 🛠 Coding Standards`,
|
|
54
|
+
`1. **Expressions**: Use \`{{ $json.field }}\` (modern) instead of \`{{ $node["Name"].json.field }}\` when possible.`,
|
|
55
|
+
`2. **Nodes**: Always prefer the \`Code\` node for custom logic.`,
|
|
56
|
+
`3. **Credentials**: NEVER hardcode API keys. Mention needed credentials by name.`,
|
|
57
|
+
``,
|
|
58
|
+
`### 🔬 Research Protocol (MANDATORY)`,
|
|
59
|
+
`Do NOT hallucinate node parameters. Use these tools via \`npx @n8n-as-code/agent-cli\`:`,
|
|
60
|
+
`- \`search "<term>"\`: Find the correct node named (camelCase).`,
|
|
61
|
+
`- \`get "<nodeName>"\`: Get the EXACT property definitions for a node.`,
|
|
62
|
+
`- \`list\`: See all available nodes.`,
|
|
63
|
+
``,
|
|
64
|
+
`Apply the Knowledge: Use the \`get\` tool's output as the absolute source of truth for JSON parameter names.`
|
|
65
|
+
].join('\n');
|
|
66
|
+
}
|
|
67
|
+
getCursorRulesContent() {
|
|
68
|
+
return [
|
|
69
|
+
`# n8n-as-code rules`,
|
|
70
|
+
`- Refer to AGENTS.md for n8n workflow standards.`,
|
|
71
|
+
`- Use @n8n-as-code/agent-cli tools to prevent parameter hallucinations.`,
|
|
72
|
+
`- Validate all workflow JSON against n8n-schema.json.`
|
|
73
|
+
].join('\n');
|
|
74
|
+
}
|
|
75
|
+
getClineRulesContent() {
|
|
76
|
+
return [
|
|
77
|
+
`n8n_engineer_role:`,
|
|
78
|
+
` description: Expert in n8n-as-code`,
|
|
79
|
+
` instructions:`,
|
|
80
|
+
` - Read AGENTS.md for core principles.`,
|
|
81
|
+
` - Use npx @n8n-as-code/agent-cli search/get before editing workflow JSON.`,
|
|
82
|
+
` - Ensure connections are correctly indexed.`
|
|
83
|
+
].join('\n');
|
|
84
|
+
}
|
|
85
|
+
getWindsurfRulesContent() {
|
|
86
|
+
return [
|
|
87
|
+
`### n8n Development Rules`,
|
|
88
|
+
`- Follow the Research Protocol in AGENTS.md.`,
|
|
89
|
+
`- Tooling: Use @n8n-as-code/agent-cli to fetch node schemas.`,
|
|
90
|
+
].join('\n');
|
|
91
|
+
}
|
|
92
|
+
getCommonRulesContent() {
|
|
93
|
+
return [
|
|
94
|
+
`# Common Rules for All AI Agents (Claude, Mistral, etc.)`,
|
|
95
|
+
`- Role: Expert n8n Automation Engineer.`,
|
|
96
|
+
`- Workflow Source of Truth: \`@n8n-as-code/agent-cli\` tools.`,
|
|
97
|
+
`- Documentation: Read AGENTS.md for full syntax rules.`
|
|
98
|
+
].join('\n');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=ai-context-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-context-generator.js","sourceRoot":"","sources":["../../src/services/ai-context-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,OAAO,kBAAkB;IAC7B,gBAAgB,CAAC;IAEjB,KAAK,CAAC,QAAQ,CAAC,WAAmB,EAAE,aAAqB,SAAS;QAChE,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACxD,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnD,MAAM,YAAY,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACjD,MAAM,eAAe,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;QACvD,MAAM,WAAW,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAEjD,uCAAuC;QACvC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;QAE9E,4BAA4B;QAC5B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE,aAAa,CAAC,CAAC;QAC3E,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,EAAE,YAAY,CAAC,CAAC;QACzE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CA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A+D;YAC/D,wDAAwD;SACzD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface INodeSchemaStub {
|
|
2
|
+
name: string;
|
|
3
|
+
displayName: string;
|
|
4
|
+
description: string;
|
|
5
|
+
version: number | number[];
|
|
6
|
+
}
|
|
7
|
+
export declare class NodeSchemaProvider {
|
|
8
|
+
private index;
|
|
9
|
+
private indexPath;
|
|
10
|
+
constructor(customIndexPath?: string);
|
|
11
|
+
private loadIndex;
|
|
12
|
+
/**
|
|
13
|
+
* Get the full JSON schema for a specific node by name.
|
|
14
|
+
* Returns null if not found.
|
|
15
|
+
*/
|
|
16
|
+
getNodeSchema(nodeName: string): any | null;
|
|
17
|
+
/**
|
|
18
|
+
* Fuzzy search for nodes.
|
|
19
|
+
* Returns a list of matches (stub only, not full schema).
|
|
20
|
+
*/
|
|
21
|
+
searchNodes(query: string): INodeSchemaStub[];
|
|
22
|
+
/**
|
|
23
|
+
* List all available nodes (compact format).
|
|
24
|
+
*/
|
|
25
|
+
listAllNodes(): INodeSchemaStub[];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=node-schema-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-schema-provider.d.ts","sourceRoot":"","sources":["../../src/services/node-schema-provider.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC9B;AAED,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,SAAS,CAAS;gBAEd,eAAe,CAAC,EAAE,MAAM;IAWpC,OAAO,CAAC,SAAS;IAcjB;;;OAGG;IACI,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI;IAelD;;;OAGG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE;IA0BpD;;OAEG;IACI,YAAY,IAAI,eAAe,EAAE;CAS3C"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
// Helper to get __dirname in ESM and CJS (bundled)
|
|
5
|
+
const _filename = typeof import.meta !== 'undefined' && import.meta.url
|
|
6
|
+
? fileURLToPath(import.meta.url)
|
|
7
|
+
: (typeof __filename !== 'undefined' ? __filename : '');
|
|
8
|
+
const _dirname = typeof __dirname !== 'undefined'
|
|
9
|
+
? __dirname
|
|
10
|
+
: path.dirname(_filename);
|
|
11
|
+
export class NodeSchemaProvider {
|
|
12
|
+
index = null;
|
|
13
|
+
indexPath;
|
|
14
|
+
constructor(customIndexPath) {
|
|
15
|
+
if (customIndexPath) {
|
|
16
|
+
this.indexPath = customIndexPath;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// Resolve path to assets/n8n-nodes-index.json
|
|
20
|
+
// In dist structure: dist/services/node-schema-provider.js -> dist/assets/n8n-nodes-index.json
|
|
21
|
+
this.indexPath = path.resolve(_dirname, '../assets/n8n-nodes-index.json');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
loadIndex() {
|
|
25
|
+
if (this.index)
|
|
26
|
+
return;
|
|
27
|
+
try {
|
|
28
|
+
if (!fs.existsSync(this.indexPath)) {
|
|
29
|
+
throw new Error(`n8n Node Index not found at: ${this.indexPath}. Run 'npm run build' in @n8n-as-code/agent-cli.`);
|
|
30
|
+
}
|
|
31
|
+
const content = fs.readFileSync(this.indexPath, 'utf-8');
|
|
32
|
+
this.index = JSON.parse(content);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new Error(`Failed to load n8n node index: ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the full JSON schema for a specific node by name.
|
|
40
|
+
* Returns null if not found.
|
|
41
|
+
*/
|
|
42
|
+
getNodeSchema(nodeName) {
|
|
43
|
+
this.loadIndex();
|
|
44
|
+
// Direct match
|
|
45
|
+
if (this.index.nodes[nodeName]) {
|
|
46
|
+
return this.index.nodes[nodeName];
|
|
47
|
+
}
|
|
48
|
+
// Case insensitive fallback
|
|
49
|
+
const lowerName = nodeName.toLowerCase();
|
|
50
|
+
const found = Object.keys(this.index.nodes).find(k => k.toLowerCase() === lowerName);
|
|
51
|
+
return found ? this.index.nodes[found] : null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Fuzzy search for nodes.
|
|
55
|
+
* Returns a list of matches (stub only, not full schema).
|
|
56
|
+
*/
|
|
57
|
+
searchNodes(query) {
|
|
58
|
+
this.loadIndex();
|
|
59
|
+
const lowerQuery = query.toLowerCase();
|
|
60
|
+
const results = [];
|
|
61
|
+
for (const [key, node] of Object.entries(this.index.nodes)) {
|
|
62
|
+
const nameMatch = key.toLowerCase().includes(lowerQuery);
|
|
63
|
+
const displayMatch = node.displayName?.toLowerCase().includes(lowerQuery);
|
|
64
|
+
const descMatch = node.description?.toLowerCase().includes(lowerQuery);
|
|
65
|
+
if (nameMatch || displayMatch || descMatch) {
|
|
66
|
+
results.push({
|
|
67
|
+
name: node.name || key,
|
|
68
|
+
displayName: node.displayName || key,
|
|
69
|
+
description: node.description || '',
|
|
70
|
+
version: node.version
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Cap results to avoid overwhelming output
|
|
74
|
+
if (results.length >= 20)
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
return results;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* List all available nodes (compact format).
|
|
81
|
+
*/
|
|
82
|
+
listAllNodes() {
|
|
83
|
+
this.loadIndex();
|
|
84
|
+
return Object.values(this.index.nodes).map(node => ({
|
|
85
|
+
name: node.name,
|
|
86
|
+
displayName: node.displayName,
|
|
87
|
+
description: node.description || '',
|
|
88
|
+
version: node.version
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=node-schema-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-schema-provider.js","sourceRoot":"","sources":["../../src/services/node-schema-provider.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,mDAAmD;AACnD,MAAM,SAAS,GAAG,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG;IACnE,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IAChC,CAAC,CAAC,CAAC,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE5D,MAAM,QAAQ,GAAG,OAAO,SAAS,KAAK,WAAW;IAC7C,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAmB,CAAC,CAAC;AASxC,MAAM,OAAO,kBAAkB;IACnB,KAAK,GAAQ,IAAI,CAAC;IAClB,SAAS,CAAS;IAE1B,YAAY,eAAwB;QAChC,IAAI,eAAe,EAAE,CAAC;YAClB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;QACrC,CAAC;aAAM,CAAC;YACJ,8CAA8C;YAC9C,+FAA+F;YAC/F,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,gCAAgC,CAAC,CAAC;QAC9E,CAAC;IACL,CAAC;IAGO,SAAS;QACb,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO;QACvB,IA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@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet-generator.d.ts","sourceRoot":"","sources":["../../src/services/snippet-generator.ts"],"names":[],"mappings":"AAGA,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe,CAAC;gBAAhB,eAAe,CAAC,EAAE,MAAM,YAAA;IAEtC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgDlD,OAAO,CAAC,mBAAmB;CA2F9B"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { NodeSchemaProvider } from './node-schema-provider.js';
|
|
3
|
+
export class SnippetGenerator {
|
|
4
|
+
customIndexPath;
|
|
5
|
+
constructor(customIndexPath) {
|
|
6
|
+
this.customIndexPath = customIndexPath;
|
|
7
|
+
}
|
|
8
|
+
async generate(projectRoot) {
|
|
9
|
+
const provider = new NodeSchemaProvider(this.customIndexPath);
|
|
10
|
+
let nodeTypes = [];
|
|
11
|
+
try {
|
|
12
|
+
nodeTypes = provider.listAllNodes();
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
// Index loading failed, fall back to hardcoded
|
|
16
|
+
console.warn("Failed to load node index for snippets, using fallbacks.");
|
|
17
|
+
}
|
|
18
|
+
const snippets = {};
|
|
19
|
+
// If no nodes found, generate generic ones
|
|
20
|
+
if (!nodeTypes || nodeTypes.length === 0) {
|
|
21
|
+
// Hardcoded common nodes for fallback
|
|
22
|
+
this.addFallbackSnippets(snippets);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
for (const node of nodeTypes) {
|
|
26
|
+
// node.name is camelCase (e.g. googleSheets).
|
|
27
|
+
// We want n8n-googleSheets
|
|
28
|
+
const key = `n8n-${node.name}`;
|
|
29
|
+
snippets[key] = {
|
|
30
|
+
prefix: key,
|
|
31
|
+
body: [
|
|
32
|
+
"{",
|
|
33
|
+
` "parameters": {},`,
|
|
34
|
+
` "name": "${node.displayName}",`,
|
|
35
|
+
` "type": "n8n-nodes-base.${node.name}",`,
|
|
36
|
+
` "typeVersion": ${Array.isArray(node.version) ? Math.max(...node.version) : node.version},`,
|
|
37
|
+
` "position": [0, 0]`,
|
|
38
|
+
"}"
|
|
39
|
+
],
|
|
40
|
+
description: `Insert a ${node.displayName} node`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const vscodeDir = `${projectRoot}/.vscode`;
|
|
45
|
+
if (!fs.existsSync(vscodeDir)) {
|
|
46
|
+
fs.mkdirSync(vscodeDir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
fs.writeFileSync(`${vscodeDir}/n8n.code-snippets`, JSON.stringify(snippets, null, 2));
|
|
49
|
+
}
|
|
50
|
+
addFallbackSnippets(snippets) {
|
|
51
|
+
const commonNodes = [
|
|
52
|
+
{
|
|
53
|
+
name: "Webhook",
|
|
54
|
+
type: "n8n-nodes-base.webhook",
|
|
55
|
+
ver: 1,
|
|
56
|
+
icon: "⚡",
|
|
57
|
+
params: { "path": "webhook", "httpMethod": "POST" }
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "Code",
|
|
61
|
+
type: "n8n-nodes-base.code",
|
|
62
|
+
ver: 2,
|
|
63
|
+
icon: "💻",
|
|
64
|
+
params: { "jsCode": "// Access data with $('NodeName').item.json\nreturn [{ json: { hello: 'world' } }];" }
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "HTTP Request",
|
|
68
|
+
type: "n8n-nodes-base.httpRequest",
|
|
69
|
+
ver: 4,
|
|
70
|
+
icon: "🌐",
|
|
71
|
+
params: { "url": "https://api.example.com", "method": "GET" }
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "Schedule Trigger",
|
|
75
|
+
type: "n8n-nodes-base.scheduleTrigger",
|
|
76
|
+
ver: 1,
|
|
77
|
+
icon: "⏰",
|
|
78
|
+
params: { "rule": { "interval": [{ "field": "minutes", "minutesInterval": 15 }] } }
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "Split In Batches",
|
|
82
|
+
type: "n8n-nodes-base.splitInBatches",
|
|
83
|
+
ver: 1,
|
|
84
|
+
icon: "📦",
|
|
85
|
+
params: { "batchSize": 10 }
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "Switch",
|
|
89
|
+
type: "n8n-nodes-base.switch",
|
|
90
|
+
ver: 1,
|
|
91
|
+
icon: "🔀",
|
|
92
|
+
params: { "datatypes": "string", "rules": { "rules": [{ "operation": "equals" }] } }
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "Merge",
|
|
96
|
+
type: "n8n-nodes-base.merge",
|
|
97
|
+
ver: 2,
|
|
98
|
+
icon: "🔗",
|
|
99
|
+
params: { "mode": "append" }
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "Google Sheets",
|
|
103
|
+
type: "n8n-nodes-base.googleSheets",
|
|
104
|
+
ver: 3,
|
|
105
|
+
icon: "📊",
|
|
106
|
+
params: { "operation": "append", "resource": "row" }
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "Slack",
|
|
110
|
+
type: "n8n-nodes-base.slack",
|
|
111
|
+
ver: 2,
|
|
112
|
+
icon: "💬",
|
|
113
|
+
params: { "channel": "general", "text": "Hello form n8n" }
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "Postgres",
|
|
117
|
+
type: "n8n-nodes-base.postgres",
|
|
118
|
+
ver: 1,
|
|
119
|
+
icon: "🐘",
|
|
120
|
+
params: { "operation": "executeQuery", "query": "SELECT * FROM users;" }
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
for (const node of commonNodes) {
|
|
124
|
+
const key = `n8n-${node.name.toLowerCase().replace(/\s+/g, '-')}`;
|
|
125
|
+
snippets[key] = {
|
|
126
|
+
prefix: key,
|
|
127
|
+
body: [
|
|
128
|
+
"{",
|
|
129
|
+
` "parameters": ${JSON.stringify(node.params)},`,
|
|
130
|
+
` "name": "${node.name}",`,
|
|
131
|
+
` "type": "${node.type}",`,
|
|
132
|
+
` "typeVersion": ${node.ver},`,
|
|
133
|
+
` "position": [0, 0]`,
|
|
134
|
+
"}"
|
|
135
|
+
],
|
|
136
|
+
description: `${node.icon} Insert a ${node.name} node`
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=snippet-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet-generator.js","sourceRoot":"","sources":["../../src/services/snippet-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,OAAO,gBAAgB;IACL;IAApB,YAAoB,eAAwB;QAAxB,oBAAe,GAAf,eAAe,CAAS;IAAI,CAAC;IAEjD,KAAK,CAAC,QAAQ,CAAC,WAAmB;QAC9B,MAAM,QAAQ,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAE9D,IAAI,SAAS,GAAU,EAAE,CAAC;QAE1B,IAAI,CAAC;YACD,SAAS,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;QACxC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,+CAA+C;YAC/C,OAAO,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,QAAQ,GAAQ,EAAE,CAAC;QAEzB,2CAA2C;QAC3C,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvC,sCAAsC;YACtC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACJ,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;gBAC3B,+CAA+C;gBAC/C,2BAA2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,EAAE,UAAU,EAAE,KAAK,EAAE;aACvD;YACD;gBACI,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,sBAAsB;gBAC5B,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE;aAC7D;YACD;gBACI,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,yBAAyB;gBAC/B,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,sBAAsB,EAAE;aAC3E;SACJ,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;YAClE,QAAQ,CAAC,GAAG,CAAC,GAAG;gBACZ,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE;oBACF,GAAG;oBACH,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;oBACjD,cAAc,IAAI,CAAC,IAAI,IAAI;oBAC3B,cAAc,IAAI,CAAC,IAAI,IAAI;oBAC3B,oBAAoB,IAAI,CAAC,GAAG,GAAG;oBAC/B,sBAAsB;oBACtB,GAAG;iBACN;gBACD,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,IAAI,OAAO;aACzD,CAAC;QACN,CAAC;IACL,CAAC;CACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@n8n-as-code/agent-cli",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "AI Agent Tools for n8n-as-code (Search, Get Schema)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"n8n-agent": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prebuild": "node ../../scripts/ensure-n8n-cache.cjs && node ../../scripts/generate-n8n-index.cjs",
|
|
13
|
+
"build": "tsc -b",
|
|
14
|
+
"postbuild": "mkdir -p dist/assets && cp src/assets/n8n-nodes-index.json dist/assets/",
|
|
15
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
16
|
+
"test": "node --experimental-vm-modules ../../node_modules/.bin/jest"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"chalk": "^4.1.2",
|
|
20
|
+
"commander": "^11.1.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/jest": "^29.5.11",
|
|
24
|
+
"@types/node": "^20.10.0",
|
|
25
|
+
"jest": "^29.7.0",
|
|
26
|
+
"ts-jest": "^29.1.1",
|
|
27
|
+
"typescript": "^5.3.3"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/",
|
|
31
|
+
"src/assets/"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
}
|
|
36
|
+
}
|