@clawos-dev/clawd 0.2.715 → 0.2.717

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.
@@ -32784,6 +32784,10 @@ var GithubPrRequestReviewersArgs = external_exports.object({
32784
32784
  number: number3,
32785
32785
  reviewers: external_exports.array(external_exports.string().min(1)).min(1)
32786
32786
  });
32787
+ var GithubReposArgs = external_exports.object({
32788
+ page: external_exports.number().int().min(1).max(1e3).optional(),
32789
+ search: external_exports.string().max(100).optional()
32790
+ });
32787
32791
 
32788
32792
  // ../protocol/src/lark-bot-schemas.ts
32789
32793
  var LarkBotPersonaArgs = external_exports.object({ personaId: external_exports.string().min(1) });
@@ -34171,6 +34175,10 @@ var METHOD_DOCS = {
34171
34175
  summary: "\u7ED9 PR \u8BF7\u6C42\u5BA1\u67E5\u8005\uFF08\u8FFD\u52A0\uFF0C\u4E0D\u8986\u76D6\u5DF2\u6709\uFF09",
34172
34176
  args: GithubPrRequestReviewersArgs
34173
34177
  },
34178
+ "github:repos": {
34179
+ summary: "\u5217\u672C\u673A GitHub \u8EAB\u4EFD\u80FD\u770B\u5230\u7684\u4ED3\u5E93\uFF08\u65B0\u5EFA\u7F16\u7801\u578B persona \u9009\u4ED3\u5E93\uFF09\uFF1A\u76F4\u8FDE GitHub REST\uFF0C\u4E0D\u4F9D\u8D56 gh\u3002\u56DE { repositories: WorkspaceRepo[], hasMore }\uFF1B\u6CA1\u5173\u8054 GitHub \u2192 UNAUTHORIZED\u300C\u8BF7\u5148\u5173\u8054 GitHub\u300D",
34180
+ args: GithubReposArgs
34181
+ },
34174
34182
  "shift-internal:add": {
34175
34183
  summary: "\u6392\u4E00\u4E2A shift\uFF08\u5230\u70B9\u81EA\u52A8\u62C9\u8D77 persona \u5E72\u6D3B\uFF09\u3002\u7701\u7565 targetPersona = \u6D3E\u7ED9\u8C03\u7528\u65B9\u81EA\u5DF1",
34176
34184
  args: ShiftInternalAddArgs
package/dist/cli.cjs CHANGED
@@ -7900,7 +7900,7 @@ var init_master = __esm({
7900
7900
  });
7901
7901
 
7902
7902
  // ../protocol/src/github.ts
7903
- var GITHUB_PR_ROLES, REPO_SEGMENT, owner, repo, number, GithubPrListArgs, GithubPrDetailArgs, GithubPrMergeArgs, GithubPrCommentArgs, GithubPrSetReadyArgs, GithubCollaboratorsArgs, GithubPrRequestReviewersArgs;
7903
+ var GITHUB_PR_ROLES, REPO_SEGMENT, owner, repo, number, GithubPrListArgs, GithubPrDetailArgs, GithubPrMergeArgs, GithubPrCommentArgs, GithubPrSetReadyArgs, GithubCollaboratorsArgs, GithubPrRequestReviewersArgs, GithubReposArgs;
7904
7904
  var init_github = __esm({
7905
7905
  "../protocol/src/github.ts"() {
7906
7906
  "use strict";
@@ -7922,6 +7922,10 @@ var init_github = __esm({
7922
7922
  number,
7923
7923
  reviewers: external_exports.array(external_exports.string().min(1)).min(1)
7924
7924
  });
7925
+ GithubReposArgs = external_exports.object({
7926
+ page: external_exports.number().int().min(1).max(1e3).optional(),
7927
+ search: external_exports.string().max(100).optional()
7928
+ });
7925
7929
  }
7926
7930
  });
7927
7931
 
@@ -9443,6 +9447,10 @@ var init_methods = __esm({
9443
9447
  summary: "\u7ED9 PR \u8BF7\u6C42\u5BA1\u67E5\u8005\uFF08\u8FFD\u52A0\uFF0C\u4E0D\u8986\u76D6\u5DF2\u6709\uFF09",
9444
9448
  args: GithubPrRequestReviewersArgs
9445
9449
  },
9450
+ "github:repos": {
9451
+ summary: "\u5217\u672C\u673A GitHub \u8EAB\u4EFD\u80FD\u770B\u5230\u7684\u4ED3\u5E93\uFF08\u65B0\u5EFA\u7F16\u7801\u578B persona \u9009\u4ED3\u5E93\uFF09\uFF1A\u76F4\u8FDE GitHub REST\uFF0C\u4E0D\u4F9D\u8D56 gh\u3002\u56DE { repositories: WorkspaceRepo[], hasMore }\uFF1B\u6CA1\u5173\u8054 GitHub \u2192 UNAUTHORIZED\u300C\u8BF7\u5148\u5173\u8054 GitHub\u300D",
9452
+ args: GithubReposArgs
9453
+ },
9446
9454
  "shift-internal:add": {
9447
9455
  summary: "\u6392\u4E00\u4E2A shift\uFF08\u5230\u70B9\u81EA\u52A8\u62C9\u8D77 persona \u5E72\u6D3B\uFF09\u3002\u7701\u7565 targetPersona = \u6D3E\u7ED9\u8C03\u7528\u65B9\u81EA\u5DF1",
9448
9456
  args: ShiftInternalAddArgs
@@ -57791,6 +57799,69 @@ function createGhRunner(defaults) {
57791
57799
  };
57792
57800
  }
57793
57801
 
57802
+ // src/github/repositories.ts
57803
+ var PAGE_SIZE = 50;
57804
+ var SEARCH_PAGE_SIZE = 100;
57805
+ var SEARCH_MAX_PAGES = 10;
57806
+ var SEARCH_CACHE_MS = 6e4;
57807
+ var PART = /^[A-Za-z0-9._-]+$/;
57808
+ function toRepo(row) {
57809
+ const r2 = row;
57810
+ const owner2 = r2?.owner?.login;
57811
+ if (typeof owner2 !== "string" || !PART.test(owner2) || typeof r2.name !== "string" || !PART.test(r2.name) || !Number.isSafeInteger(r2.id) || r2.id < 1)
57812
+ throw new Error("GitHub \u56DE\u7684\u4ED3\u5E93\u5217\u8868\u683C\u5F0F\u4E0D\u5BF9");
57813
+ return {
57814
+ repoId: String(r2.id),
57815
+ owner: owner2,
57816
+ name: r2.name,
57817
+ defaultBranch: typeof r2.default_branch === "string" ? r2.default_branch : "",
57818
+ private: Boolean(r2.private),
57819
+ description: typeof r2.description === "string" ? r2.description : null
57820
+ };
57821
+ }
57822
+ function createRepoList(deps) {
57823
+ let everything;
57824
+ async function fetchPage(perPage, page) {
57825
+ const rows = await deps.get(
57826
+ `/user/repos?per_page=${perPage}&page=${page}&sort=pushed&affiliation=owner,collaborator,organization_member`
57827
+ );
57828
+ if (!Array.isArray(rows)) throw new Error("GitHub \u56DE\u7684\u4ED3\u5E93\u5217\u8868\u683C\u5F0F\u4E0D\u5BF9");
57829
+ return rows.map(toRepo);
57830
+ }
57831
+ async function fetchAll() {
57832
+ const found = [];
57833
+ for (let n2 = 1; n2 <= SEARCH_MAX_PAGES; n2++) {
57834
+ const rows = await fetchPage(SEARCH_PAGE_SIZE, n2);
57835
+ found.push(...rows);
57836
+ if (rows.length < SEARCH_PAGE_SIZE) break;
57837
+ }
57838
+ return found;
57839
+ }
57840
+ return {
57841
+ async list(page, search) {
57842
+ const needle = search.trim().toLowerCase();
57843
+ if (!needle) {
57844
+ const repositories = await fetchPage(PAGE_SIZE, page);
57845
+ return { repositories, hasMore: repositories.length === PAGE_SIZE };
57846
+ }
57847
+ if (!everything || deps.now() - everything.at >= SEARCH_CACHE_MS) {
57848
+ const repos = fetchAll();
57849
+ everything = { at: deps.now(), repos };
57850
+ repos.catch(() => {
57851
+ if (everything?.repos === repos) everything = void 0;
57852
+ });
57853
+ }
57854
+ const matched = (await everything.repos).filter(
57855
+ (r2) => `${r2.owner}/${r2.name}`.toLowerCase().includes(needle)
57856
+ );
57857
+ return {
57858
+ repositories: matched.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE),
57859
+ hasMore: matched.length > page * PAGE_SIZE
57860
+ };
57861
+ }
57862
+ };
57863
+ }
57864
+
57794
57865
  // src/shift/scheduler.ts
57795
57866
  function cleanupOrphanRunningRuns(store, now) {
57796
57867
  for (const shift of store.list()) {
@@ -62573,8 +62644,8 @@ function createGithubApi(args) {
62573
62644
  return void 0;
62574
62645
  }
62575
62646
  },
62576
- async getJsonStrict(path113) {
62577
- return must("GET", path113, "\u8BFB\u53D6\u53D1\u5E03\u8BB0\u5F55");
62647
+ async getJsonStrict(path113, what = "\u8BFB\u53D6\u53D1\u5E03\u8BB0\u5F55") {
62648
+ return must("GET", path113, what);
62578
62649
  },
62579
62650
  async downloadArtifact(slug, artifactId) {
62580
62651
  if (!Number.isSafeInteger(artifactId) || artifactId <= 0) throw new GithubApiError(0, "\u5236\u54C1 ID \u65E0\u6548");
@@ -75842,6 +75913,7 @@ var METHOD_GRANT_MAP = {
75842
75913
  "github:prSetReady": ADMIN_ANY,
75843
75914
  "github:collaborators": ADMIN_ANY,
75844
75915
  "github:prRequestReviewers": ADMIN_ANY,
75916
+ "github:repos": ADMIN_ANY,
75845
75917
  // These programmatic entry points require the owner token; business attribution is handled separately.
75846
75918
  "shift-internal:add": ADMIN_ANY,
75847
75919
  "shift-internal:list": ADMIN_ANY,
@@ -75979,7 +76051,7 @@ function computeMethodAccess(args) {
75979
76051
  }
75980
76052
 
75981
76053
  // src/version.ts
75982
- var version = "0.2.715".length > 0 ? "0.2.715" : "dev";
76054
+ var version = "0.2.717".length > 0 ? "0.2.717" : "dev";
75983
76055
 
75984
76056
  // src/cli-probe/probe.ts
75985
76057
  var fs87 = __toESM(require("fs"), 1);
@@ -77537,7 +77609,7 @@ function parsePrDetailResponse(json, repoRef) {
77537
77609
 
77538
77610
  // src/handlers/github.ts
77539
77611
  function buildGithubHandlers(deps) {
77540
- const { gh, identity } = deps;
77612
+ const { gh, identity, repos } = deps;
77541
77613
  return {
77542
77614
  "github:status": async () => {
77543
77615
  try {
@@ -77632,6 +77704,17 @@ function buildGithubHandlers(deps) {
77632
77704
  for (const r2 of reviewers) args.push("-f", `reviewers[]=${r2}`);
77633
77705
  await gh.run(args);
77634
77706
  return { response: { requested: true } };
77707
+ },
77708
+ "github:repos": async (frame) => {
77709
+ const { page, search } = GithubReposArgs.parse(frame);
77710
+ try {
77711
+ const r2 = await repos.list(page ?? 1, search ?? "");
77712
+ return { response: r2 };
77713
+ } catch (err) {
77714
+ if (err instanceof GithubApiError && err.status === 401)
77715
+ throw new ClawdError(ERROR_CODES.UNAUTHORIZED, "\u8BF7\u5148\u5173\u8054 GitHub");
77716
+ throw err;
77717
+ }
77635
77718
  }
77636
77719
  };
77637
77720
  }
@@ -77985,7 +78068,7 @@ function buildMethodHandlers(deps) {
77985
78068
  ownerIdProvider: deps.shiftOwnerIdProvider,
77986
78069
  now: () => Date.now()
77987
78070
  }),
77988
- ...buildGithubHandlers({ gh: deps.ghRunner, identity: deps.githubIdentity }),
78071
+ ...buildGithubHandlers({ gh: deps.ghRunner, identity: deps.githubIdentity, repos: deps.githubRepos }),
77989
78072
  ...buildVisitorHandlers({ visitorStore: deps.visitorStore }),
77990
78073
  ...buildWebHandlers({ issueLaunchUrl: deps.issueWebLaunchUrl })
77991
78074
  };
@@ -79575,6 +79658,11 @@ async function startDaemon(config) {
79575
79658
  // PR 收件箱:github:* handler spawn 本机 gh CLI,凭据是 clawd 的 GitHub 身份(GH_TOKEN),没有才是 gh 自己的登录态
79576
79659
  ghRunner: createGhRunner({ token: async () => (await githubIdentity.refresh())?.token }),
79577
79660
  githubIdentity,
79661
+ // 新建编码型 persona 选仓库:同一份身份直连 GitHub REST
79662
+ githubRepos: (() => {
79663
+ const api = createGithubApi({ token: "", identity: githubIdentity });
79664
+ return createRepoList({ get: (path113) => api.getJsonStrict(path113, "\u8BFB\u53D6\u4ED3\u5E93\u5217\u8868"), now: Date.now });
79665
+ })(),
79578
79666
  visitorStore,
79579
79667
  issueWebLaunchUrl
79580
79668
  })