Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ rulesync.local.jsonc
**/.factory/droids/
**/.gemini/agents/
**/.goose/recipes/subagents/
**/.hermes/rulesync/subagents/
**/.grok/agents/
**/.junie/agents/
**/.kiro/agents/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ The tables below show whether each tool supports a given feature (✅ = supporte
| GitHub Copilot | ✅ | | ✅ | ✅ | ✅ | ✅ | ✅ | |
| GitHub Copilot CLI | ✅ | | ✅ | | ✅ | ✅ | ✅ | |
| Goose | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Hermes Agent | ✅ | | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Grok CLI | ✅ | | ✅ | | ✅ | ✅ | | ✅ |
| Hermes Agent | ✅ | | ✅ | | | | | |
| Cursor | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| deepagents-cli | ✅ | | ✅ | | ✅ | ✅ | ✅ | |
| Factory Droid | ✅ | | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Expand Down
6 changes: 6 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
"agentsignore",
"agentsmd",
"agentsskills",
"isinstance",
"kwargs",
"pathlib",
"subagent",
"subagents",
"toolsets",
"ampcode",
"aiexclude",
"aiglobal",
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/supported-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Rulesync supports both **generation** and **import** for All of the major AI cod
| GitHub Copilot | copilot | ✅ 🌏 | | ✅ | ✅ | ✅ 🌏 | ✅ | ✅ | |
| GitHub Copilot CLI | copilotcli | ✅ 🌏 | | ✅ 🌏 | | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | |
| Goose | goose | ✅ 🌏 | ✅ | 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ | ✅ 🌏 | 🌏 |
| Hermes Agent | hermesagent | ✅ | | 🌏 | 🌏 | ✅ 🌏 | 🌏 | 🌏 | 🌏 |
| Grok CLI | grokcli | ✅ 🌏 | | ✅ 🌏 | | ✅ 🌏 | ✅ 🌏 | | 🌏 |
| Hermes Agent | hermesagent | ✅ | | 🌏 | | | | | |
| Cursor | cursor | ✅ | ✅ | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 |
| deepagents-cli | deepagents | ✅ 🌏 | | ✅ 🌏 | | ✅ 🌏 | ✅ 🌏 | 🌏 | |
| Factory Droid | factorydroid | ✅ 🌏 | | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 |
Expand Down
2 changes: 1 addition & 1 deletion skills/rulesync/supported-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Rulesync supports both **generation** and **import** for All of the major AI cod
| GitHub Copilot | copilot | ✅ 🌏 | | ✅ | ✅ | ✅ 🌏 | ✅ | ✅ | |
| GitHub Copilot CLI | copilotcli | ✅ 🌏 | | ✅ 🌏 | | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | |
| Goose | goose | ✅ 🌏 | ✅ | 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ | ✅ 🌏 | 🌏 |
| Hermes Agent | hermesagent | ✅ | | 🌏 | 🌏 | ✅ 🌏 | 🌏 | 🌏 | 🌏 |
| Grok CLI | grokcli | ✅ 🌏 | | ✅ 🌏 | | ✅ 🌏 | ✅ 🌏 | | 🌏 |
| Hermes Agent | hermesagent | ✅ | | 🌏 | | | | | |
| Cursor | cursor | ✅ | ✅ | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 |
| deepagents-cli | deepagents | ✅ 🌏 | | ✅ 🌏 | | ✅ 🌏 | ✅ 🌏 | 🌏 | |
| Factory Droid | factorydroid | ✅ 🌏 | | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 | ✅ 🌏 |
Expand Down
27 changes: 27 additions & 0 deletions src/constants/hermesagent-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,30 @@ export const HERMESAGENT_GLOBAL_DIR = ".hermes";

/** MCP servers and other settings live in `config.yaml` under `~/.hermes/`. */
export const HERMESAGENT_MCP_FILE_NAME = "config.yaml";
export const HERMESAGENT_SOUL_FILE_NAME = "SOUL.md";
export const HERMESAGENT_CONFIG_FILE_NAME = "config.yaml";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HERMESAGENT_CONFIG_FILE_NAME and HERMESAGENT_MCP_FILE_NAME are both "config.yaml". Two constants for the same value invites drift — consider collapsing to one.

export const HERMESAGENT_SOUL_FILE_PATH = join(HERMESAGENT_GLOBAL_DIR, HERMESAGENT_SOUL_FILE_NAME);
export const HERMESAGENT_CONFIG_FILE_PATH = join(
HERMESAGENT_GLOBAL_DIR,
HERMESAGENT_CONFIG_FILE_NAME,
);
export const HERMESAGENT_SKILLS_DIR_PATH = join(HERMESAGENT_GLOBAL_DIR, "skills");
export const HERMESAGENT_RULESYNC_DIR_PATH = join(HERMESAGENT_GLOBAL_DIR, "rulesync");
export const HERMESAGENT_RULESYNC_SUBAGENTS_DIR_PATH = join(
HERMESAGENT_RULESYNC_DIR_PATH,
"subagents",
);
export const HERMESAGENT_RULESYNC_SUBAGENTS_PLUGIN_DIR_PATH = join(
HERMESAGENT_GLOBAL_DIR,
"plugins",
"rulesync-subagents",
);
export const HERMESAGENT_RULESYNC_SUBAGENTS_PLUGIN_MANIFEST_PATH = join(
HERMESAGENT_RULESYNC_SUBAGENTS_PLUGIN_DIR_PATH,
"plugin.yaml",
);
export const HERMESAGENT_RULESYNC_SUBAGENTS_PLUGIN_INIT_PATH = join(
HERMESAGENT_RULESYNC_SUBAGENTS_PLUGIN_DIR_PATH,
"__init__.py",
);
import { join } from "node:path";
3 changes: 2 additions & 1 deletion src/features/commands/commands-processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1202,12 +1202,13 @@ describe("CommandsProcessor", () => {
"claudecode",
"claudecode-legacy",
"cline",
"codexcli",
"cursor",
"factorydroid",
"geminicli",
"goose",
"hermesagent",
"junie",
"codexcli",
"kilo",
"opencode",
"pi",
Expand Down
14 changes: 14 additions & 0 deletions src/features/commands/commands-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { DevinCommand } from "./devin-command.js";
import { FactorydroidCommand } from "./factorydroid-command.js";
import { GeminiCliCommand } from "./geminicli-command.js";
import { GooseCommand } from "./goose-command.js";
import { HermesagentCommand } from "./hermesagent-command.js";
import { JunieCommand } from "./junie-command.js";
import { KiloCommand } from "./kilo-command.js";
import { KiroCliCommand } from "./kiro-cli-command.js";
Expand Down Expand Up @@ -269,6 +270,19 @@ export const toolCommandFactories = new Map<CommandsProcessorToolTarget, ToolCom
},
},
],
[
"hermesagent",
{
class: HermesagentCommand,
meta: {
extension: "md",
supportsProject: false,
supportsGlobal: true,
isSimulated: false,
supportsSubdirectory: true,
},
},
],
[
"junie",
{
Expand Down
50 changes: 50 additions & 0 deletions src/features/commands/hermesagent-command.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { describe, expect, it } from "vitest";

import { RULESYNC_COMMANDS_RELATIVE_DIR_PATH } from "../../constants/rulesync-paths.js";
import { HermesagentCommand } from "./hermesagent-command.js";
import { RulesyncCommand } from "./rulesync-command.js";

describe("HermesagentCommand", () => {
it("uses rulesync command description and body when generating SKILL.md", () => {
const rulesyncCommand = new RulesyncCommand({
relativeDirPath: RULESYNC_COMMANDS_RELATIVE_DIR_PATH,
relativeFilePath: `${RULESYNC_COMMANDS_RELATIVE_DIR_PATH}/review.md`,
frontmatter: {
description: "Review the current changes",
},
body: "Review the diff carefully.",
fileContent: "",
});

const command = HermesagentCommand.fromRulesyncCommand({
outputRoot: ".",
rulesyncCommand,
});

expect(command.getFileContent()).toContain("description: Review the current changes");
expect(command.getFileContent()).toContain("Review the diff carefully.");
expect(command.getFileContent()).not.toContain("targets:");
});

it("strips Hermes skill frontmatter when importing back to rulesync command", () => {
const command = new HermesagentCommand({
relativeDirPath: ".hermes/skills/review",
relativeFilePath: "SKILL.md",
fileContent: [
"---",
"name: review",
"description: Review the current changes",
"---",
"",
"Review the diff carefully.",
"",
].join("\n"),
});

const rulesyncCommand = command.toRulesyncCommand();

expect(rulesyncCommand.getFrontmatter().description).toBe("Review the current changes");
expect(rulesyncCommand.getBody()).toBe("Review the diff carefully.\n");
expect(rulesyncCommand.getBody()).not.toContain("---");
});
});
86 changes: 86 additions & 0 deletions src/features/commands/hermesagent-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { basename, dirname, join } from "node:path";

import { HERMESAGENT_SKILLS_DIR_PATH } from "../../constants/hermesagent-paths.js";
import { RULESYNC_COMMANDS_RELATIVE_DIR_PATH } from "../../constants/rulesync-paths.js";
import { type AiFileParams, ValidationResult } from "../../types/ai-file.js";
import { parseFrontmatter, stringifyFrontmatter } from "../../utils/frontmatter.js";
import { RulesyncCommand } from "./rulesync-command.js";
import { ToolCommand, type ToolCommandFromRulesyncCommandParams } from "./tool-command.js";

const SKILL_FILE_NAME = "SKILL.md";

type HermesagentCommandParams = AiFileParams & {
slug?: string;
};

function commandSlug(relativeFilePath: string): string {
return basename(relativeFilePath, ".md").replace(/[^a-zA-Z0-9_-]/g, "-");
}

function commandSkillContent(rulesyncCommand: RulesyncCommand): string {
const slug = commandSlug(rulesyncCommand.getRelativeFilePath());
const description = rulesyncCommand.getFrontmatter().description ?? `${slug} command`;

return stringifyFrontmatter(rulesyncCommand.getBody().trim(), {
name: slug,
description,
});
}

export class HermesagentCommand extends ToolCommand {
static override isTargetedByRulesyncCommand(rulesyncCommand: RulesyncCommand): boolean {
const targets = rulesyncCommand.getFrontmatter().targets;

return !targets || targets.includes("*") || targets.includes("hermesagent");
}

static getSettablePaths({ slug = "command" }: { slug?: string; global?: boolean } = {}) {
return {
relativeDirPath: join(HERMESAGENT_SKILLS_DIR_PATH, slug),
relativeFilePath: SKILL_FILE_NAME,
};
}

constructor({ slug, ...params }: HermesagentCommandParams) {
const resolvedSlug =
slug ?? basename(dirname(params.relativeDirPath)) ?? commandSlug(params.relativeFilePath);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basename(dirname(...)) never returns nullish, so the ?? commandSlug(...) fallback is dead code. Minor, but worth trimming for clarity.

super({
...params,
...HermesagentCommand.getSettablePaths({ slug: resolvedSlug }),
});
}

validate(): ValidationResult {
return { success: true, error: null };
}

toRulesyncCommand(): RulesyncCommand {
const slug = basename(dirname(this.getRelativePathFromCwd()));
const { frontmatter, body } = parseFrontmatter(this.getFileContent(), this.getFilePath());
const description =
typeof frontmatter.description === "string" ? frontmatter.description : undefined;

return new RulesyncCommand({
relativeDirPath: RULESYNC_COMMANDS_RELATIVE_DIR_PATH,
relativeFilePath: `${slug}.md`,
frontmatter: { description },
body: body.trimStart(),
} as ConstructorParameters<typeof RulesyncCommand>[0]);
}

static override fromRulesyncCommand({
outputRoot,
rulesyncCommand,
}: ToolCommandFromRulesyncCommandParams): HermesagentCommand {
return new HermesagentCommand({
outputRoot,
relativeDirPath: "",
relativeFilePath: SKILL_FILE_NAME,
slug: commandSlug(rulesyncCommand.getRelativeFilePath()),
fileContent: commandSkillContent(rulesyncCommand),
});
}
getFileContent(): string {
return this.fileContent;
}
}
40 changes: 40 additions & 0 deletions src/features/hermes-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { describe, expect, it } from "vitest";

import { parseHermesConfig } from "./hermes-config.js";

describe("parseHermesConfig", () => {
it("returns empty config for non-object YAML roots", () => {
expect(parseHermesConfig("- item")).toEqual({});
});

it("drops prototype-pollution keys recursively", () => {
const config = parseHermesConfig(`
model: hermes-3
__proto__:
polluted: true
mcp_servers:
docs:
url: https://example.com/mcp
constructor:
polluted: true
plugins:
enabled:
- rulesync-subagents
prototype:
polluted: true
`);

expect(config).toEqual({
model: "hermes-3",
mcp_servers: {
docs: {
url: "https://example.com/mcp",
},
},
plugins: {
enabled: ["rulesync-subagents"],
},
});
expect(({} as Record<string, unknown>).polluted).toBeUndefined();
});
});
54 changes: 54 additions & 0 deletions src/features/hermes-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { dump, load } from "js-yaml";

import {
omitPrototypePollutionKeys,
PROTOTYPE_POLLUTION_KEYS,
} from "../utils/prototype-pollution.js";
import { isPlainObject } from "../utils/type-guards.js";

type HermesConfig = Record<string, unknown>;

function sanitizeHermesConfigValue(value: unknown): unknown {
if (Array.isArray(value)) {
return value.map(sanitizeHermesConfigValue);
}

if (!isPlainObject(value)) {
return value;
}

const sanitized = omitPrototypePollutionKeys(value);
const result: Record<string, unknown> = {};

for (const [key, nestedValue] of Object.entries(sanitized)) {
if (PROTOTYPE_POLLUTION_KEYS.has(key)) continue;
result[key] = sanitizeHermesConfigValue(nestedValue);
}

return result;
}

export function parseHermesConfig(fileContent: string): HermesConfig {
if (!fileContent.trim()) {
return {};
}

const parsed = load(fileContent);

if (isPlainObject(parsed)) {
return sanitizeHermesConfigValue(parsed) as HermesConfig;
}

return {};
}

export function stringifyHermesConfig(config: HermesConfig): string {
return dump(config, { noRefs: true, sortKeys: false }).trimEnd() + "\n";
}

export function mergeHermesConfig(fileContent: string, patch: HermesConfig): string {
return stringifyHermesConfig({
...parseHermesConfig(fileContent),
...patch,
});
}
Loading
Loading