@husar.ai/cli 0.2.14 → 0.3.2
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/MCP_SERVER.md +11 -20
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/functions/parser.d.ts +11 -6
- package/dist/functions/parser.js +14 -22
- package/dist/functions/parser.js.map +1 -1
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +509 -91
- package/dist/mcp.js.map +1 -1
- package/dist/types/config.d.ts +7 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/zeus/const.js +906 -413
- package/dist/zeus/const.js.map +1 -1
- package/dist/zeus/index.d.ts +3973 -1770
- package/dist/zeus/index.js +39 -11
- package/dist/zeus/index.js.map +1 -1
- package/package.json +3 -2
- package/src/cli.ts +6 -11
- package/src/functions/generate.ts +0 -1
- package/src/functions/parser.ts +28 -25
- package/src/mcp.ts +579 -99
- package/src/types/config.ts +7 -0
- package/src/zeus/const.ts +936 -413
- package/src/zeus/index.ts +3854 -1791
- package/dist/scripts/mcp-generate-test.d.ts +0 -1
- package/dist/scripts/mcp-generate-test.js +0 -28
- package/dist/scripts/mcp-generate-test.js.map +0 -1
- package/src/scripts/mcp-generate-test.ts +0 -34
package/MCP_SERVER.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MCP Server Setup (Cursor + Codex)
|
|
2
2
|
|
|
3
|
-
This guide shows how to register the Husar MCP server so your AI tools can call the CLI commands
|
|
3
|
+
This guide shows how to register the Husar MCP server so your AI tools can call the CLI commands
|
|
4
4
|
|
|
5
5
|
The MCP server is built into the CLI. Run it as `husar.ai mcp`.
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ The MCP server is built into the CLI. Run it as `husar.ai mcp`.
|
|
|
10
10
|
- Ensure your workspace (project root) contains `husar.json` with:
|
|
11
11
|
- `host`: Husar CMS base URL
|
|
12
12
|
- `adminToken`: Husar admin token (required for copy/upsert)
|
|
13
|
-
- Use
|
|
13
|
+
- Use `@husar.ai/cli generate` or edit `husar.json` directly to set these.
|
|
14
14
|
|
|
15
15
|
No environment variables are required. MCP reads config like the CLI and auto-detects the workspace root.
|
|
16
16
|
|
|
@@ -22,8 +22,8 @@ Create or edit `~/.cursor/mcp.json` and add the Husar server entry.
|
|
|
22
22
|
{
|
|
23
23
|
"mcpServers": {
|
|
24
24
|
"husar": {
|
|
25
|
-
"command": "
|
|
26
|
-
"args": ["mcp"]
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "@husar.ai/cli", "mcp"]
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -40,7 +40,7 @@ Create or edit `~/.config/codex/config.toml` and add a server entry.
|
|
|
40
40
|
```toml
|
|
41
41
|
[mcp_servers.husar]
|
|
42
42
|
command = "husar.ai"
|
|
43
|
-
args = ["mcp"]
|
|
43
|
+
args = ["-y", "@husar.ai/cli", "mcp"]
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Notes:
|
|
@@ -49,28 +49,20 @@ Notes:
|
|
|
49
49
|
|
|
50
50
|
## Available Tools
|
|
51
51
|
|
|
52
|
-
- `
|
|
52
|
+
- `husar_copy`:
|
|
53
53
|
- Purpose: Parse a CMS file into a shape or model and upsert via CLI.
|
|
54
54
|
- Inputs:
|
|
55
|
-
- `path`: Absolute path or path relative to the
|
|
55
|
+
- `path`: Absolute path or path relative to the workspace root.
|
|
56
56
|
- `type`: Optional, `"model" | "shape"` (default `"shape"`).
|
|
57
57
|
- `name`: Optional string; if omitted, derived from filename (lowercased).
|
|
58
|
+
- `workspaceRoot`: Optional string; Target folder for where husar.json is located. Needed when run in monorepo where husar.json is located in child repo
|
|
58
59
|
- Output: JSON stringified status or error details.
|
|
59
|
-
- Notes: This maps to the `husar_copy` implementation; kept for compatibility.
|
|
60
|
-
|
|
61
|
-
- `husar_copy`:
|
|
62
|
-
- Purpose: Same as `cms_parse_file` (alias of the CLI `copy` command).
|
|
63
|
-
- Inputs: Same as `cms_parse_file`.
|
|
64
|
-
- Auth: Reads `host` and `adminToken` from `husar.json` at the workspace root (same as CLI).
|
|
65
|
-
- Example arguments:
|
|
66
|
-
- `path`: `packages/playground/src/pages/examples/ContactForm.tsx`
|
|
67
|
-
- `type`: `shape`
|
|
68
|
-
- `name`: `examples_contactform`
|
|
69
60
|
|
|
70
61
|
- `husar_generate`:
|
|
71
62
|
- Purpose: Generate CMS scaffolding (Zeus client, host helpers, SSR + React helpers) into `cms/`.
|
|
72
63
|
- Inputs:
|
|
73
|
-
- `folderPath`: Optional target directory relative to the
|
|
64
|
+
- `folderPath`: Optional target directory relative to the workspace root (defaults to `"."`). The `cms/` folder is created/rewritten inside this path.
|
|
65
|
+
- `workspaceRoot`: Optional string; Target folder for where husar.json is located. Needed when run in monorepo where husar.json is located in child repo
|
|
74
66
|
- Host config: Uses `host` from `husar.json` at the workspace root.
|
|
75
67
|
- Output: JSON with `{ "status": "ok", "folder": "<ABS_PATH_TO_cms>" }` or error details.
|
|
76
68
|
- Files written:
|
|
@@ -80,5 +72,4 @@ Notes:
|
|
|
80
72
|
## Troubleshooting
|
|
81
73
|
|
|
82
74
|
- CLI not found: Ensure `@husar.ai/cli` is installed globally or that `husar.ai` is on PATH.
|
|
83
|
-
- Config errors: Make sure `husar.json` at your workspace root contains `host` and `adminToken
|
|
84
|
-
- Workspace detection: The server walks up from its current working directory to find a `package.json` with `workspaces`. Launch it from within your project.
|
|
75
|
+
- Config errors: Make sure `husar.json` at your workspace root contains `host` and `adminToken` for admin actions.
|
package/dist/cli.js
CHANGED
|
@@ -34,7 +34,11 @@ program
|
|
|
34
34
|
if (!conf.adminToken) {
|
|
35
35
|
throw new Error('Admin token is not configured. Please set it in the config or use environment variable.');
|
|
36
36
|
}
|
|
37
|
-
const result = await parser(
|
|
37
|
+
const result = await parser({
|
|
38
|
+
inputFile,
|
|
39
|
+
opts: { name, type: opts?.type },
|
|
40
|
+
authentication: { HUSAR_MCP_HOST: conf.host, HUSAR_MCP_ADMIN_TOKEN: conf.adminToken },
|
|
41
|
+
});
|
|
38
42
|
console.log(result ? 'File parsed and upserted successfully.' : 'Failed to parse and upsert file.');
|
|
39
43
|
});
|
|
40
44
|
program
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,MAAM,GAAG,IAAI,WAAW,CAAkB,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;AAE3E,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,mCAAmC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAExF,OAAO;KACJ,OAAO,CAAC,uBAAuB,CAAC;KAChC,WAAW,CAAC,0CAA0C,CAAC;KACvD,MAAM,CAAC,KAAK,EAAE,aAAqB,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AAC,CAAC,CAAC,kCAAkC,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,qCAAqC,CAAC;KAClD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,cAAc,EAAE,CAAC;IAGvB,MAAM,IAAI,OAAO,CAAO,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
export declare const parser: (inputFile
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare const parser: ({ authentication, inputFile, opts, workspaceRoot, }: {
|
|
2
|
+
inputFile: string;
|
|
3
|
+
workspaceRoot?: string;
|
|
4
|
+
opts: {
|
|
5
|
+
name: string;
|
|
6
|
+
type: "model" | "shape";
|
|
7
|
+
};
|
|
8
|
+
authentication: {
|
|
9
|
+
HUSAR_MCP_HOST: string;
|
|
10
|
+
HUSAR_MCP_ADMIN_TOKEN: string;
|
|
11
|
+
};
|
|
7
12
|
}) => Promise<boolean>;
|
package/dist/functions/parser.js
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import * as fs from 'node:fs/promises';
|
|
3
|
-
export const parser = async (inputFile, opts,
|
|
3
|
+
export const parser = async ({ authentication, inputFile, opts, workspaceRoot, }) => {
|
|
4
4
|
const { HUSAR_MCP_ADMIN_TOKEN, HUSAR_MCP_HOST } = authentication;
|
|
5
5
|
const filename = path.basename(inputFile);
|
|
6
|
-
const body = await fs.readFile(path.resolve(process.cwd(), inputFile), 'utf8');
|
|
6
|
+
const body = await fs.readFile(path.resolve(process.cwd(), ...(workspaceRoot ? [workspaceRoot] : []), inputFile), 'utf8');
|
|
7
7
|
const key = `${opts.name}-${filename}-${new Date().getTime()}.txt`;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
putURL = result?.data?.admin?.uploadFile?.putURL;
|
|
20
|
-
fileURL = result?.data?.admin?.uploadFile?.cdnURL;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
console.log('Failed to get upload URL');
|
|
24
|
-
throw new Error('Failed to get upload URL');
|
|
25
|
-
}
|
|
8
|
+
const put = await fetch(new URL('api/graphql', HUSAR_MCP_HOST).toString(), {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers: { 'Content-Type': 'application/json', husar_token: HUSAR_MCP_ADMIN_TOKEN },
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
query: `mutation GetUploadURL($input: UploadFileInput!) { admin { uploadFile(file: $input) { putURL cdnURL } } }`,
|
|
13
|
+
variables: { input: { prefix: 'parse', key } },
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
const result = await put.json();
|
|
17
|
+
const putURL = result?.data?.admin?.uploadFile?.putURL;
|
|
18
|
+
const fileURL = result?.data?.admin?.uploadFile?.cdnURL;
|
|
26
19
|
if (!putURL) {
|
|
27
|
-
|
|
28
|
-
throw new Error('Failed to get upload URL');
|
|
20
|
+
throw new Error(`Failed to get upload URL ${JSON.stringify(result, null, 2)} ,`);
|
|
29
21
|
}
|
|
30
22
|
try {
|
|
31
23
|
await fetch(putURL, { method: 'PUT', headers: { 'Content-Type': 'text/plain', 'x-amz-acl': 'public-read' }, body });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/functions/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,MAAM,CAAC,M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