@gh-symphony/cli 0.0.14 → 0.0.16

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.
Files changed (102) hide show
  1. package/dist/chunk-5NV3LSAJ.js +11 -0
  2. package/dist/chunk-6HBZC3BE.js +468 -0
  3. package/dist/chunk-76QPITKI.js +109 -0
  4. package/dist/chunk-EFMFGOWM.js +3575 -0
  5. package/dist/chunk-IWR4UQEJ.js +2250 -0
  6. package/dist/chunk-JO3AXHQI.js +130 -0
  7. package/dist/chunk-MHIWAIVD.js +876 -0
  8. package/dist/chunk-MVRF7BES.js +68 -0
  9. package/dist/chunk-ROGRTUFI.js +108 -0
  10. package/dist/chunk-TF3QNWNC.js +1121 -0
  11. package/dist/chunk-TH5QPO3Y.js +67 -0
  12. package/dist/config-cmd-AZ7POMAA.js +110 -0
  13. package/dist/index.d.ts +5 -4
  14. package/dist/index.js +568 -356
  15. package/dist/init-EZXQAXZM.js +17 -0
  16. package/dist/logs-6LNGT2GF.js +188 -0
  17. package/dist/project-557FE2GD.js +679 -0
  18. package/dist/recover-LVBI2TGH.js +131 -0
  19. package/dist/repo-R3XBIVAX.js +121 -0
  20. package/dist/run-WITYAYFZ.js +108 -0
  21. package/dist/start-JUFKNL3N.js +16 -0
  22. package/dist/status-3WK5BWRZ.js +11 -0
  23. package/dist/stop-AA3AP5M6.js +9 -0
  24. package/dist/version-VBB62JWI.js +30 -0
  25. package/dist/worker-entry.js +1828 -0
  26. package/package.json +9 -4
  27. package/dist/ansi.d.ts +0 -15
  28. package/dist/ansi.js +0 -53
  29. package/dist/commands/config-cmd.d.ts +0 -3
  30. package/dist/commands/config-cmd.js +0 -90
  31. package/dist/commands/help.d.ts +0 -3
  32. package/dist/commands/help.js +0 -55
  33. package/dist/commands/init.d.ts +0 -34
  34. package/dist/commands/init.js +0 -477
  35. package/dist/commands/logs.d.ts +0 -3
  36. package/dist/commands/logs.js +0 -184
  37. package/dist/commands/project.d.ts +0 -3
  38. package/dist/commands/project.js +0 -649
  39. package/dist/commands/recover.d.ts +0 -3
  40. package/dist/commands/recover.js +0 -119
  41. package/dist/commands/repo.d.ts +0 -3
  42. package/dist/commands/repo.js +0 -103
  43. package/dist/commands/run.d.ts +0 -3
  44. package/dist/commands/run.js +0 -95
  45. package/dist/commands/start.d.ts +0 -20
  46. package/dist/commands/start.js +0 -344
  47. package/dist/commands/status-refresh.d.ts +0 -9
  48. package/dist/commands/status-refresh.js +0 -27
  49. package/dist/commands/status.d.ts +0 -3
  50. package/dist/commands/status.js +0 -237
  51. package/dist/commands/stop.d.ts +0 -3
  52. package/dist/commands/stop.js +0 -92
  53. package/dist/commands/version.d.ts +0 -3
  54. package/dist/commands/version.js +0 -21
  55. package/dist/completion.d.ts +0 -1
  56. package/dist/completion.js +0 -204
  57. package/dist/config.d.ts +0 -38
  58. package/dist/config.js +0 -82
  59. package/dist/context/context-types.d.ts +0 -36
  60. package/dist/context/context-types.js +0 -1
  61. package/dist/context/generate-context-yaml.d.ts +0 -15
  62. package/dist/context/generate-context-yaml.js +0 -129
  63. package/dist/dashboard/renderer.d.ts +0 -9
  64. package/dist/dashboard/renderer.js +0 -220
  65. package/dist/detection/environment-detector.d.ts +0 -11
  66. package/dist/detection/environment-detector.js +0 -140
  67. package/dist/github/client.d.ts +0 -71
  68. package/dist/github/client.js +0 -348
  69. package/dist/github/gh-auth.d.ts +0 -34
  70. package/dist/github/gh-auth.js +0 -110
  71. package/dist/mapping/smart-defaults.d.ts +0 -17
  72. package/dist/mapping/smart-defaults.js +0 -86
  73. package/dist/orchestrator-runtime.d.ts +0 -1
  74. package/dist/orchestrator-runtime.js +0 -4
  75. package/dist/orchestrator-status-endpoint.d.ts +0 -5
  76. package/dist/orchestrator-status-endpoint.js +0 -27
  77. package/dist/project-selection.d.ts +0 -8
  78. package/dist/project-selection.js +0 -56
  79. package/dist/skills/skill-writer.d.ts +0 -14
  80. package/dist/skills/skill-writer.js +0 -62
  81. package/dist/skills/templates/commit.d.ts +0 -2
  82. package/dist/skills/templates/commit.js +0 -45
  83. package/dist/skills/templates/document.d.ts +0 -7
  84. package/dist/skills/templates/document.js +0 -16
  85. package/dist/skills/templates/gh-project.d.ts +0 -2
  86. package/dist/skills/templates/gh-project.js +0 -88
  87. package/dist/skills/templates/gh-symphony.d.ts +0 -2
  88. package/dist/skills/templates/gh-symphony.js +0 -125
  89. package/dist/skills/templates/index.d.ts +0 -8
  90. package/dist/skills/templates/index.js +0 -28
  91. package/dist/skills/templates/land.d.ts +0 -2
  92. package/dist/skills/templates/land.js +0 -59
  93. package/dist/skills/templates/pull.d.ts +0 -2
  94. package/dist/skills/templates/pull.js +0 -41
  95. package/dist/skills/templates/push.d.ts +0 -2
  96. package/dist/skills/templates/push.js +0 -36
  97. package/dist/skills/types.d.ts +0 -23
  98. package/dist/skills/types.js +0 -1
  99. package/dist/workflow/generate-reference-workflow.d.ts +0 -9
  100. package/dist/workflow/generate-reference-workflow.js +0 -261
  101. package/dist/workflow/generate-workflow-md.d.ts +0 -12
  102. package/dist/workflow/generate-workflow-md.js +0 -134
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/github/gh-auth.ts
4
+ import { execFileSync, spawnSync } from "child_process";
5
+ var REQUIRED_SCOPES = ["repo", "read:org", "project"];
6
+ var GhAuthError = class extends Error {
7
+ constructor(code, message) {
8
+ super(message);
9
+ this.code = code;
10
+ this.name = "GhAuthError";
11
+ }
12
+ };
13
+ function checkGhInstalled(opts) {
14
+ const execImpl = opts?.execImpl ?? execFileSync;
15
+ try {
16
+ execImpl("gh", ["--version"], { stdio: "pipe" });
17
+ return true;
18
+ } catch (error) {
19
+ const execError = error;
20
+ if (execError.code === "ENOENT") {
21
+ return false;
22
+ }
23
+ throw error;
24
+ }
25
+ }
26
+ function checkGhAuthenticated(opts) {
27
+ const spawnImpl = opts?.spawnImpl ?? spawnSync;
28
+ const result = spawnImpl("gh", ["auth", "status"], {
29
+ encoding: "utf8",
30
+ stdio: ["pipe", "pipe", "pipe"]
31
+ });
32
+ if ((result.status ?? 1) !== 0) {
33
+ return { authenticated: false };
34
+ }
35
+ const login = parseLogin((result.stdout ?? "").toString());
36
+ return { authenticated: true, login };
37
+ }
38
+ function checkGhScopes(opts) {
39
+ const spawnImpl = opts?.spawnImpl ?? spawnSync;
40
+ const result = spawnImpl("gh", ["auth", "status"], {
41
+ encoding: "utf8",
42
+ stdio: ["pipe", "pipe", "pipe"]
43
+ });
44
+ const output = (result.stdout ?? "").toString();
45
+ const scopes = parseScopes(output);
46
+ if (scopes.length === 0) {
47
+ return { valid: true, missing: [], scopes: [] };
48
+ }
49
+ const normalized = scopes.map((scope) => scope.toLowerCase());
50
+ const missing = REQUIRED_SCOPES.filter(
51
+ (scope) => !normalized.includes(scope)
52
+ );
53
+ return {
54
+ valid: missing.length === 0,
55
+ missing: [...missing],
56
+ scopes
57
+ };
58
+ }
59
+ function getGhToken(opts) {
60
+ if (process.env.GITHUB_GRAPHQL_TOKEN) {
61
+ return process.env.GITHUB_GRAPHQL_TOKEN;
62
+ }
63
+ const execImpl = opts?.execImpl ?? execFileSync;
64
+ try {
65
+ const token = execImpl("gh", ["auth", "token"], {
66
+ encoding: "utf8",
67
+ stdio: ["pipe", "pipe", "pipe"]
68
+ }).toString().trim();
69
+ if (!token) {
70
+ throw new GhAuthError(
71
+ "token_failed",
72
+ "gh auth token \uC2E4\uD328. gh auth status \uB97C \uD655\uC778\uD558\uC138\uC694."
73
+ );
74
+ }
75
+ return token;
76
+ } catch (error) {
77
+ if (error instanceof GhAuthError) {
78
+ throw error;
79
+ }
80
+ throw new GhAuthError(
81
+ "token_failed",
82
+ "gh auth token \uC2E4\uD328. gh auth status \uB97C \uD655\uC778\uD558\uC138\uC694."
83
+ );
84
+ }
85
+ }
86
+ function ensureGhAuth(opts) {
87
+ const execImpl = opts?.execImpl ?? execFileSync;
88
+ const spawnImpl = opts?.spawnImpl ?? spawnSync;
89
+ if (!checkGhInstalled({ execImpl })) {
90
+ throw new GhAuthError(
91
+ "not_installed",
92
+ "gh CLI\uAC00 \uC124\uCE58\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. https://cli.github.com \uC5D0\uC11C \uC124\uCE58\uD558\uC138\uC694."
93
+ );
94
+ }
95
+ const auth = checkGhAuthenticated({ spawnImpl });
96
+ if (!auth.authenticated) {
97
+ throw new GhAuthError(
98
+ "not_authenticated",
99
+ "gh auth login --scopes repo,read:org,project \uB97C \uC2E4\uD589\uD558\uC138\uC694."
100
+ );
101
+ }
102
+ const scopeCheck = checkGhScopes({ spawnImpl });
103
+ if (!scopeCheck.valid) {
104
+ throw new GhAuthError(
105
+ "missing_scopes",
106
+ `gh auth refresh --scopes repo,read:org,project \uB97C \uC2E4\uD589\uD558\uC138\uC694. (missing: ${scopeCheck.missing.join(", ")})`
107
+ );
108
+ }
109
+ const token = getGhToken({ execImpl });
110
+ return { login: auth.login ?? "unknown", token };
111
+ }
112
+ function parseLogin(output) {
113
+ const matched = output.match(
114
+ /Logged in to github\.com account\s+\*?\*?([A-Za-z0-9_-]+)\*?\*?/i
115
+ );
116
+ return matched?.[1];
117
+ }
118
+ function parseScopes(output) {
119
+ const matched = output.match(/Token scopes:\s*(.+)/i);
120
+ if (!matched) {
121
+ return [];
122
+ }
123
+ return matched[1].split(",").map((scope) => scope.trim().replace(/^'+|'+$/g, "")).filter((scope) => scope.length > 0);
124
+ }
125
+
126
+ export {
127
+ GhAuthError,
128
+ getGhToken,
129
+ ensureGhAuth
130
+ };