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
3 changes: 2 additions & 1 deletion scripts/build-binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function parseGitDescribe(describe) {
function calculateMinVer() {
// Allow override via environment (for Docker/CI)
if (process.env.VERSION) {
return process.env.VERSION;
// Strip leading "v" if present — callers add their own prefix
return process.env.VERSION.replace(/^v/i, "");
}
try {
const result = spawnSync("git", ["describe", "--tags", "--long", "--always", "--dirty"], {
Expand Down
3 changes: 2 additions & 1 deletion src/agent/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export function getVersion(): string {

// Check for build-time injected version
if (typeof __HYPERAGENT_VERSION__ !== "undefined") {
cachedVersion = __HYPERAGENT_VERSION__;
// Strip leading "v" if present — callers add their own prefix
cachedVersion = __HYPERAGENT_VERSION__.replace(/^v/i, "");
return cachedVersion;
}

Expand Down
10 changes: 10 additions & 0 deletions src/plugin-system/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ export function validateManifest(raw: unknown): string[] {
if ("version" in obj && typeof obj.version !== "string") {
errors.push("version must be a string");
}
if (
"version" in obj &&
typeof obj.version === "string" &&
/^v/i.test(obj.version)
) {
// Callers prepend "v" for display — a prefixed version causes "vv1.0.0"
errors.push(
'version must not start with "v" (use bare semver, e.g. "1.0.0")',
);
}
if ("description" in obj && typeof obj.description !== "string") {
errors.push("description must be a string");
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugin-system/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface ConfigSchemaEntry {
export interface PluginManifest {
/** Unique plugin name (kebab-case, matches directory name). */
name: string;
/** SemVer version string. */
/** SemVer version string (bare, no "v" prefix — e.g. "1.0.0" not "v1.0.0"). */
version: string;
/** One-line description of what the plugin does. */
description: string;
Expand Down
13 changes: 13 additions & 0 deletions tests/plugin-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ describe("validateManifest", () => {
expect(errors).toContain("hostModules must be an array");
});

it('should reject version with "v" prefix', () => {
const manifest = {
name: "test",
version: "v1.0.0",
description: "Test",
hostModules: ["fs"],
};
const errors = validateManifest(manifest);
expect(errors).toContain(
'version must not start with "v" (use bare semver, e.g. "1.0.0")',
);
});

it("should reject empty hostModules array", () => {
const manifest = {
name: "test",
Expand Down
Loading