@h-rig/standard-plugin 0.0.6-alpha.103 → 0.0.6-alpha.119

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.
@@ -22,23 +22,29 @@ function createEnvGitHubCredentialProvider() {
22
22
  };
23
23
  }
24
24
  function createStateGitHubCredentialProvider(options = {}) {
25
- const resolveStateFile = () => {
25
+ const stateFileCandidates = () => {
26
+ const candidates = [];
26
27
  const explicitFile = options.stateFile ?? process.env.RIG_GITHUB_AUTH_STATE_FILE;
27
28
  if (explicitFile?.trim())
28
- return resolve(explicitFile.trim());
29
- const stateDir = options.stateDir ?? process.env.RIG_STATE_DIR;
30
- return stateDir?.trim() ? resolve(stateDir.trim(), "github-auth.json") : null;
29
+ candidates.push(resolve(explicitFile.trim()));
30
+ for (const dir of [options.stateDir, process.env.RIG_STATE_DIR]) {
31
+ if (dir?.trim())
32
+ candidates.push(resolve(dir.trim(), "github-auth.json"));
33
+ }
34
+ return candidates;
31
35
  };
32
36
  const readToken = () => {
33
- const stateFile = resolveStateFile();
34
- if (!stateFile || !existsSync(stateFile))
35
- return null;
36
- try {
37
- const parsed = JSON.parse(readFileSync(stateFile, "utf8"));
38
- return typeof parsed.token === "string" ? cleanToken(parsed.token) : null;
39
- } catch {
40
- return null;
37
+ for (const stateFile of stateFileCandidates()) {
38
+ if (!existsSync(stateFile))
39
+ continue;
40
+ try {
41
+ const parsed = JSON.parse(readFileSync(stateFile, "utf8"));
42
+ const token = typeof parsed.token === "string" ? cleanToken(parsed.token) : null;
43
+ if (token)
44
+ return token;
45
+ } catch {}
41
46
  }
47
+ return null;
42
48
  };
43
49
  return {
44
50
  async resolveGitHubToken(input) {
@@ -664,9 +670,10 @@ function createGitHubIssuesTaskSource(opts) {
664
670
  return issues.map((i) => issueToTask(i, repo));
665
671
  },
666
672
  async get(id) {
673
+ const env = await resolveCredentialEnv(opts, "selected-repo");
674
+ let issue;
667
675
  try {
668
- const env = await resolveCredentialEnv(opts, "selected-repo");
669
- const issue = runGh(bin, [
676
+ issue = runGh(bin, [
670
677
  "issue",
671
678
  "view",
672
679
  String(id),
@@ -675,10 +682,14 @@ function createGitHubIssuesTaskSource(opts) {
675
682
  "--json",
676
683
  "number,title,body,labels,state,url,assignees,id"
677
684
  ], spawnFn, env, timeoutMs);
678
- return issueToTask(issue, repo);
679
- } catch {
680
- return;
685
+ } catch (error) {
686
+ const detail = error instanceof Error ? error.message : String(error);
687
+ if (/could not resolve to (an? )?(issue|pullrequest)|no issues? (found|matched)|404 not found|gh: not found/i.test(detail)) {
688
+ return;
689
+ }
690
+ throw new Error(`Failed to read task ${id} from GitHub repo ${repo}: ${detail}`);
681
691
  }
692
+ return issueToTask(issue, repo);
682
693
  },
683
694
  async updateStatus(id, status) {
684
695
  const env = await resolveCredentialEnv(opts, "selected-repo");
package/dist/src/index.js CHANGED
@@ -26,23 +26,29 @@ function createEnvGitHubCredentialProvider() {
26
26
  };
27
27
  }
28
28
  function createStateGitHubCredentialProvider(options = {}) {
29
- const resolveStateFile = () => {
29
+ const stateFileCandidates = () => {
30
+ const candidates = [];
30
31
  const explicitFile = options.stateFile ?? process.env.RIG_GITHUB_AUTH_STATE_FILE;
31
32
  if (explicitFile?.trim())
32
- return resolve(explicitFile.trim());
33
- const stateDir = options.stateDir ?? process.env.RIG_STATE_DIR;
34
- return stateDir?.trim() ? resolve(stateDir.trim(), "github-auth.json") : null;
33
+ candidates.push(resolve(explicitFile.trim()));
34
+ for (const dir of [options.stateDir, process.env.RIG_STATE_DIR]) {
35
+ if (dir?.trim())
36
+ candidates.push(resolve(dir.trim(), "github-auth.json"));
37
+ }
38
+ return candidates;
35
39
  };
36
40
  const readToken = () => {
37
- const stateFile = resolveStateFile();
38
- if (!stateFile || !existsSync(stateFile))
39
- return null;
40
- try {
41
- const parsed = JSON.parse(readFileSync(stateFile, "utf8"));
42
- return typeof parsed.token === "string" ? cleanToken(parsed.token) : null;
43
- } catch {
44
- return null;
41
+ for (const stateFile of stateFileCandidates()) {
42
+ if (!existsSync(stateFile))
43
+ continue;
44
+ try {
45
+ const parsed = JSON.parse(readFileSync(stateFile, "utf8"));
46
+ const token = typeof parsed.token === "string" ? cleanToken(parsed.token) : null;
47
+ if (token)
48
+ return token;
49
+ } catch {}
45
50
  }
51
+ return null;
46
52
  };
47
53
  return {
48
54
  async resolveGitHubToken(input) {
@@ -668,9 +674,10 @@ function createGitHubIssuesTaskSource(opts) {
668
674
  return issues.map((i) => issueToTask(i, repo));
669
675
  },
670
676
  async get(id) {
677
+ const env = await resolveCredentialEnv(opts, "selected-repo");
678
+ let issue;
671
679
  try {
672
- const env = await resolveCredentialEnv(opts, "selected-repo");
673
- const issue = runGh(bin, [
680
+ issue = runGh(bin, [
674
681
  "issue",
675
682
  "view",
676
683
  String(id),
@@ -679,10 +686,14 @@ function createGitHubIssuesTaskSource(opts) {
679
686
  "--json",
680
687
  "number,title,body,labels,state,url,assignees,id"
681
688
  ], spawnFn, env, timeoutMs);
682
- return issueToTask(issue, repo);
683
- } catch {
684
- return;
689
+ } catch (error) {
690
+ const detail = error instanceof Error ? error.message : String(error);
691
+ if (/could not resolve to (an? )?(issue|pullrequest)|no issues? (found|matched)|404 not found|gh: not found/i.test(detail)) {
692
+ return;
693
+ }
694
+ throw new Error(`Failed to read task ${id} from GitHub repo ${repo}: ${detail}`);
685
695
  }
696
+ return issueToTask(issue, repo);
686
697
  },
687
698
  async updateStatus(id, status) {
688
699
  const env = await resolveCredentialEnv(opts, "selected-repo");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/standard-plugin",
3
- "version": "0.0.6-alpha.103",
3
+ "version": "0.0.6-alpha.119",
4
4
  "type": "module",
5
5
  "description": "First-party contribution bundle for Rig's OMP extension plugin graph; not a standalone plugin runtime.",
6
6
  "license": "UNLICENSED",
@@ -21,8 +21,8 @@
21
21
  "module": "./dist/src/index.js",
22
22
  "types": "./dist/src/index.d.ts",
23
23
  "dependencies": {
24
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.103",
25
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.103",
24
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.119",
25
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.119",
26
26
  "effect": "4.0.0-beta.78"
27
27
  }
28
28
  }