glab-agent 0.2.4 → 0.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glab-agent",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "description": "Multi-agent GitLab To-Do watcher with YAML-defined agents, skills, and GitLab registry.",
6
6
  "license": "MIT",
@@ -91,10 +91,10 @@ export interface GitlabClient {
91
91
  updateUserStatus(emoji: string, message: string, availability?: "busy" | "not_set"): Promise<void>;
92
92
  updateUserBio(bio: string): Promise<void>;
93
93
  listAllPendingTodos(): Promise<GitlabTodoItem[]>;
94
- listWikiPages(projectId: number): Promise<WikiPage[]>;
95
- getWikiPage(projectId: number, slug: string): Promise<WikiPage>;
96
- createWikiPage(projectId: number, title: string, content: string): Promise<WikiPage>;
97
- updateWikiPage(projectId: number, slug: string, title: string, content: string): Promise<WikiPage>;
94
+ listWikiPages(projectId: number | string): Promise<WikiPage[]>;
95
+ getWikiPage(projectId: number | string, slug: string): Promise<WikiPage>;
96
+ createWikiPage(projectId: number | string, title: string, content: string): Promise<WikiPage>;
97
+ updateWikiPage(projectId: number | string, slug: string, title: string, content: string): Promise<WikiPage>;
98
98
  }
99
99
 
100
100
  interface GitlabGlabClientOptions {
@@ -632,7 +632,7 @@ export class GitlabGlabClient implements GitlabClient {
632
632
  });
633
633
  }
634
634
 
635
- async listWikiPages(projectId: number): Promise<WikiPage[]> {
635
+ async listWikiPages(projectId: number | string): Promise<WikiPage[]> {
636
636
  const endpoint = this.withQuery(`projects/${projectId}/wikis`, { with_content: "0" });
637
637
  let payload: unknown;
638
638
  try {
@@ -656,7 +656,7 @@ export class GitlabGlabClient implements GitlabClient {
656
656
  .filter((w): w is WikiPage => w !== undefined);
657
657
  }
658
658
 
659
- async getWikiPage(projectId: number, slug: string): Promise<WikiPage> {
659
+ async getWikiPage(projectId: number | string, slug: string): Promise<WikiPage> {
660
660
  const payload = await this.readJson(`projects/${projectId}/wikis/${encodeURIComponent(slug)}`);
661
661
  const p = (payload ?? {}) as Payload;
662
662
  return {
@@ -666,7 +666,7 @@ export class GitlabGlabClient implements GitlabClient {
666
666
  };
667
667
  }
668
668
 
669
- async createWikiPage(projectId: number, title: string, content: string): Promise<WikiPage> {
669
+ async createWikiPage(projectId: number | string, title: string, content: string): Promise<WikiPage> {
670
670
  const stdout = await this.request(`projects/${projectId}/wikis`, {
671
671
  method: "POST",
672
672
  fields: { title, content }
@@ -679,7 +679,7 @@ export class GitlabGlabClient implements GitlabClient {
679
679
  };
680
680
  }
681
681
 
682
- async updateWikiPage(projectId: number, slug: string, title: string, content: string): Promise<WikiPage> {
682
+ async updateWikiPage(projectId: number | string, slug: string, title: string, content: string): Promise<WikiPage> {
683
683
  // title must be passed to preserve directory prefix in slug (GitLab API quirk)
684
684
  const stdout = await this.request(`projects/${projectId}/wikis/${encodeURIComponent(slug)}`, {
685
685
  method: "PUT",
@@ -803,7 +803,22 @@ async function publishAgentProfileWiki(
803
803
  ): Promise<void> {
804
804
  const logger = dependencies.logger ?? console;
805
805
  const def = config.agentDefinition;
806
- if (!def || !config.gitlabProjectId) return;
806
+ if (!def) return;
807
+
808
+ // Resolve project identifier: explicit/inferred ID, or encoded path from git remote
809
+ let projectRef: number | string | undefined = config.gitlabProjectId;
810
+ if (!projectRef) {
811
+ const remoteUrl = readOriginRemote(config.agentRepoPath, execFileSync);
812
+ const remote = remoteUrl ? parseGitRemoteUrl(remoteUrl) : undefined;
813
+ if (remote) {
814
+ // GitLab API accepts URL-encoded project path as project ID
815
+ const projectPath = remote.projectPath.startsWith("git/")
816
+ ? remote.projectPath.replace(/^git\//, "")
817
+ : remote.projectPath;
818
+ projectRef = encodeURIComponent(projectPath);
819
+ }
820
+ }
821
+ if (!projectRef) return;
807
822
 
808
823
  const agentName = def.name;
809
824
  const slug = `agents/${agentName}`;
@@ -854,12 +869,12 @@ async function publishAgentProfileWiki(
854
869
  const content = lines.join("\n");
855
870
 
856
871
  try {
857
- const pages = await dependencies.gitlabClient.listWikiPages(config.gitlabProjectId);
872
+ const pages = await dependencies.gitlabClient.listWikiPages(projectRef);
858
873
  const existing = pages.find(p => p.slug === slug || p.slug === `agents-${agentName}`);
859
874
  if (existing) {
860
- await dependencies.gitlabClient.updateWikiPage(config.gitlabProjectId, existing.slug, slug, content);
875
+ await dependencies.gitlabClient.updateWikiPage(projectRef, existing.slug, slug, content);
861
876
  } else {
862
- await dependencies.gitlabClient.createWikiPage(config.gitlabProjectId, slug, content);
877
+ await dependencies.gitlabClient.createWikiPage(projectRef, slug, content);
863
878
  }
864
879
  logger.info(`Wiki profile published: agents/${agentName}`);
865
880
  } catch (error) {