Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(agent): add profile name and user content management

Jiang Bohana80c858ce59d
diff --git a/src/agent/async-agent.ts b/src/agent/async-agent.ts
index 86ae5d90f5..cee3b3e8e8 100644
--- a/src/agent/async-agent.ts
+++ b/src/agent/async-agent.ts
@@ -148,4 +148,32 @@ export class AsyncAgent {
getProfileId(): string | undefined {
return this.agent.getProfileId();
}
+
+ /**
+ * Get agent display name from profile config.
+ */
+ getAgentName(): string | undefined {
+ return this.agent.getAgentName();
+ }
+
+ /**
+ * Update agent display name in profile config.
+ */
+ setAgentName(name: string): void {
+ this.agent.setAgentName(name);
+ }
+
+ /**
+ * Get user.md content from profile.
+ */
+ getUserContent(): string | undefined {
+ return this.agent.getUserContent();
+ }
+
+ /**
+ * Update user.md content in profile.
+ */
+ setUserContent(content: string): void {
+ this.agent.setUserContent(content);
+ }
}
diff --git a/src/agent/profile/index.ts b/src/agent/profile/index.ts
index bc41e0461a..556dead3fb 100644
--- a/src/agent/profile/index.ts
+++ b/src/agent/profile/index.ts
@@ -13,7 +13,10 @@ import {
loadProfile,
profileExists,
saveProfile,
+ writeProfileConfig,
+ writeProfileFile,
} from "./storage.js";
+import { PROFILE_FILES } from "./types.js";
export { type AgentProfile, type CreateProfileOptions, type ProfileConfig, type ProfileManagerOptions } from "./types.js";
export { DEFAULT_TEMPLATES } from "./templates.js";
@@ -215,4 +218,38 @@ export class ProfileManager {
this.updateToolsConfig(newConfig);
return newConfig;
}
+
+ /** 获取 Agent 名称 */
+ getName(): string | undefined {
+ const profile = this.getProfile();
+ return profile?.config?.name;
+ }
+
+ /** 更新 Agent 名称 */
+ updateName(name: string): void {
+ const profile = this.getOrCreateProfile(false);
+ const currentConfig = profile.config ?? {};
+ const newConfig: ProfileConfig = {
+ ...currentConfig,
+ name,
+ };
+ profile.config = newConfig;
+ this.profile = profile;
+ writeProfileConfig(this.profileId, newConfig, { baseDir: this.baseDir });
+ }
+
+ /** 获取 user.md 内容 */
+ getUserContent(): string | undefined {
+ const profile = this.getProfile();
+ return profile?.user;
+ }
+
+ /** 更新 user.md 内容 */
+ updateUserContent(content: string): void {
+ writeProfileFile(this.profileId, PROFILE_FILES.user, content, { baseDir: this.baseDir });
+ // Update cached profile
+ if (this.profile) {
+ this.profile.user = content;
+ }
+ }
}
diff --git a/src/agent/profile/types.ts b/src/agent/profile/types.ts
index 4565d7df72..db313ceb1a 100644
--- a/src/agent/profile/types.ts
+++ b/src/agent/profile/types.ts
@@ -15,6 +15,8 @@ export const PROFILE_FILES = {
/** Profile config.json structure */
export interface ProfileConfig {
+ /** Agent display name */
+ name?: string;
/** Tools policy configuration */
tools?: ToolsConfig;
/** Default LLM provider */
diff --git a/src/agent/runner.ts b/src/agent/runner.ts
index bdc9e2036c..9a013e93d7 100644
--- a/src/agent/runner.ts
+++ b/src/agent/runner.ts
@@ -532,4 +532,32 @@ export class Agent {
getProfileId(): string | undefined {
return this.profile?.getProfile()?.id;
}
+
+ /**
+ * Get agent display name from profile config.
+ */
+ getAgentName(): string | undefined {
+ return this.profile?.getName();
+ }
+
+ /**
+ * Update agent display name in profile config.
+ */
+ setAgentName(name: string): void {
+ this.profile?.updateName(name);
+ }
+
+ /**
+ * Get user.md content from profile.
+ */
+ getUserContent(): string | undefined {
+ return this.profile?.getUserContent();
+ }
+
+ /**
+ * Update user.md content in profile.
+ */
+ setUserContent(content: string): void {
+ this.profile?.updateUserContent(content);
+ }
}