@ghx-dev/core 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -268,11 +268,11 @@ const result = await executeTask(
268
268
 
269
269
  ## Documentation
270
270
 
271
- - [Architecture overview](https://github.com/aryeko/ghx/blob/main/docs/CODEMAPS/ARCHITECTURE.md)
272
- - [Module map](https://github.com/aryeko/ghx/blob/main/docs/CODEMAPS/MODULES.md)
273
- - [File map](https://github.com/aryeko/ghx/blob/main/docs/CODEMAPS/FILES.md)
274
- - [Operation card registry](https://github.com/aryeko/ghx/blob/main/docs/architecture/operation-card-registry.md)
275
- - [Publishing guide](https://github.com/aryeko/ghx/blob/main/docs/guides/publishing.md)
271
+ - [Documentation Hub](https://github.com/aryeko/ghx/blob/main/docs/README.md)
272
+ - [Architecture](https://github.com/aryeko/ghx/blob/main/docs/architecture/README.md)
273
+ - [Capabilities Reference](https://github.com/aryeko/ghx/blob/main/docs/capabilities/README.md)
274
+ - [Operation Cards](https://github.com/aryeko/ghx/blob/main/docs/architecture/operation-cards.md)
275
+ - [Publishing Guide](https://github.com/aryeko/ghx/blob/main/docs/contributing/publishing.md)
276
276
 
277
277
  ## License
278
278
 
package/dist/agent.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  explainCapability,
3
3
  listCapabilities
4
- } from "./chunk-SCIJMW5P.js";
5
- import "./chunk-OL4ARD3R.js";
4
+ } from "./chunk-2FCPR3XZ.js";
5
+ import "./chunk-UN5YHUNK.js";
6
6
 
7
7
  // src/agent-interface/prompt/main-skill.ts
8
8
  var MAIN_SKILL_TEXT = `
@@ -23,9 +23,7 @@ function createExecuteTool(deps) {
23
23
  input: params,
24
24
  ...options ? { options } : {}
25
25
  };
26
- return deps.executeTask({
27
- ...request
28
- });
26
+ return deps.executeTask(request);
29
27
  }
30
28
  };
31
29
  }
package/dist/agent.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/agent-interface/prompt/main-skill.ts","../src/agent-interface/tools/execute-tool.ts"],"sourcesContent":["export const MAIN_SKILL_TEXT = `\nUse execute(capability_id, params) for all GitHub actions.\nNever call gh help and never fetch GraphQL schema/introspection.\nIf required params are unknown, call explain(capability_id) or ask the user.\nTreat ResultEnvelope.ok=false as a failure.\nIf error.retryable=true, retry once unless user requested otherwise.\nOnly reason about ResultEnvelope.data and ResultEnvelope.error.\n`.trim()\n","import type { ResultEnvelope } from \"../../core/contracts/envelope.js\"\n\ntype ExecuteTaskFn = (request: {\n task: string\n input: Record<string, unknown>\n options?: Record<string, unknown>\n}) => Promise<ResultEnvelope>\n\nexport function createExecuteTool(deps: { executeTask: ExecuteTaskFn }) {\n return {\n execute(\n capabilityId: string,\n params: Record<string, unknown>,\n options?: Record<string, unknown>,\n ): Promise<ResultEnvelope> {\n const request = {\n task: capabilityId,\n input: params,\n ...(options ? { options } : {}),\n }\n\n return deps.executeTask({\n ...request,\n })\n },\n }\n}\n"],"mappings":";;;;;;;AAAO,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO7B,KAAK;;;ACCA,SAAS,kBAAkB,MAAsC;AACtE,SAAO;AAAA,IACL,QACE,cACA,QACA,SACyB;AACzB,YAAM,UAAU;AAAA,QACd,MAAM;AAAA,QACN,OAAO;AAAA,QACP,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAA,MAC/B;AAEA,aAAO,KAAK,YAAY;AAAA,QACtB,GAAG;AAAA,MACL,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/agent-interface/prompt/main-skill.ts","../src/agent-interface/tools/execute-tool.ts"],"sourcesContent":["export const MAIN_SKILL_TEXT = `\nUse execute(capability_id, params) for all GitHub actions.\nNever call gh help and never fetch GraphQL schema/introspection.\nIf required params are unknown, call explain(capability_id) or ask the user.\nTreat ResultEnvelope.ok=false as a failure.\nIf error.retryable=true, retry once unless user requested otherwise.\nOnly reason about ResultEnvelope.data and ResultEnvelope.error.\n`.trim()\n","import type { ResultEnvelope } from \"../../core/contracts/envelope.js\"\n\ntype ExecuteTaskFn = (request: {\n task: string\n input: Record<string, unknown>\n options?: Record<string, unknown>\n}) => Promise<ResultEnvelope>\n\nexport function createExecuteTool(deps: { executeTask: ExecuteTaskFn }) {\n return {\n execute(\n capabilityId: string,\n params: Record<string, unknown>,\n options?: Record<string, unknown>,\n ): Promise<ResultEnvelope> {\n const request = {\n task: capabilityId,\n input: params,\n ...(options ? { options } : {}),\n }\n\n return deps.executeTask(request)\n },\n }\n}\n"],"mappings":";;;;;;;AAAO,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO7B,KAAK;;;ACCA,SAAS,kBAAkB,MAAsC;AACtE,SAAO;AAAA,IACL,QACE,cACA,QACA,SACyB;AACzB,YAAM,UAAU;AAAA,QACd,MAAM;AAAA,QACN,OAAO;AAAA,QACP,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAA,MAC/B;AAEA,aAAO,KAAK,YAAY,OAAO;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
@@ -31,7 +31,7 @@ output_schema:
31
31
  additionalProperties: false
32
32
  additionalProperties: false
33
33
  routing:
34
- preferred: graphql
35
- fallbacks: [cli]
34
+ preferred: cli
35
+ fallbacks: []
36
36
  cli:
37
37
  command: project field-list
@@ -17,7 +17,7 @@ output_schema:
17
17
  added: { type: boolean }
18
18
  additionalProperties: false
19
19
  routing:
20
- preferred: graphql
21
- fallbacks: [cli]
20
+ preferred: cli
21
+ fallbacks: []
22
22
  cli:
23
23
  command: project item-add
@@ -23,7 +23,7 @@ output_schema:
23
23
  updated: { type: boolean }
24
24
  additionalProperties: false
25
25
  routing:
26
- preferred: graphql
27
- fallbacks: [cli]
26
+ preferred: cli
27
+ fallbacks: []
28
28
  cli:
29
29
  command: project item-edit
@@ -33,7 +33,7 @@ output_schema:
33
33
  additionalProperties: false
34
34
  additionalProperties: false
35
35
  routing:
36
- preferred: graphql
37
- fallbacks: [cli]
36
+ preferred: cli
37
+ fallbacks: []
38
38
  cli:
39
39
  command: project item-list
@@ -20,7 +20,7 @@ output_schema:
20
20
  url: { type: [string, "null"] }
21
21
  additionalProperties: false
22
22
  routing:
23
- preferred: graphql
24
- fallbacks: [cli]
23
+ preferred: cli
24
+ fallbacks: []
25
25
  cli:
26
26
  command: project view
@@ -20,7 +20,7 @@ output_schema:
20
20
  url: { type: [string, "null"] }
21
21
  additionalProperties: false
22
22
  routing:
23
- preferred: graphql
24
- fallbacks: [cli]
23
+ preferred: cli
24
+ fallbacks: []
25
25
  cli:
26
26
  command: project view
@@ -34,7 +34,7 @@ output_schema:
34
34
  additionalProperties: false
35
35
  additionalProperties: false
36
36
  routing:
37
- preferred: graphql
38
- fallbacks: [cli]
37
+ preferred: cli
38
+ fallbacks: []
39
39
  cli:
40
40
  command: api graphql
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getOperationCard,
3
3
  listOperationCards
4
- } from "./chunk-OL4ARD3R.js";
4
+ } from "./chunk-UN5YHUNK.js";
5
5
 
6
6
  // src/agent-interface/tools/explain-tool.ts
7
7
  function extractRequiredInputs(inputSchema) {
@@ -51,4 +51,4 @@ export {
51
51
  explainCapability,
52
52
  listCapabilities
53
53
  };
54
- //# sourceMappingURL=chunk-SCIJMW5P.js.map
54
+ //# sourceMappingURL=chunk-2FCPR3XZ.js.map
@@ -1,6 +1,7 @@
1
1
  import {
2
+ ajv,
2
3
  getOperationCard
3
- } from "./chunk-OL4ARD3R.js";
4
+ } from "./chunk-UN5YHUNK.js";
4
5
 
5
6
  // src/core/execution/cli/safe-runner.ts
6
7
  import { spawn } from "child_process";
@@ -146,11 +147,6 @@ function normalizeError(error, route, options) {
146
147
  }
147
148
 
148
149
  // src/core/registry/schema-validator.ts
149
- import { Ajv } from "ajv";
150
- var ajv = new Ajv({
151
- allErrors: true,
152
- strict: false
153
- });
154
150
  var validatorCache = /* @__PURE__ */ new WeakMap();
155
151
  function mapAjvErrors(errors) {
156
152
  if (!errors) {
@@ -422,17 +418,20 @@ function toMessage(error) {
422
418
  }
423
419
  function mapErrorToCode(error) {
424
420
  const message = toMessage(error).toLowerCase();
425
- if (message.includes("rate limit") || message.includes(" 429") || message.includes("too many requests")) {
421
+ if (message.includes("rate limit") || /\b429\b/.test(message) || message.includes("too many requests")) {
426
422
  return errorCodes.RateLimit;
427
423
  }
424
+ if (/\b(500|502|503|504)\b/.test(message)) {
425
+ return errorCodes.Server;
426
+ }
428
427
  if (message.includes("timeout")) {
429
428
  return errorCodes.Network;
430
429
  }
431
430
  if (message.includes("econn") || message.includes("enotfound") || message.includes("eai_again") || message.includes("network") || message.includes("connection reset")) {
432
431
  return errorCodes.Network;
433
432
  }
434
- if (message.includes(" 500") || message.includes(" 502") || message.includes(" 503") || message.includes(" 504")) {
435
- return errorCodes.Server;
433
+ if (message.includes("not found") || /\b404\b/.test(message)) {
434
+ return errorCodes.NotFound;
436
435
  }
437
436
  if (message.includes("auth") || message.includes("forbidden") || message.includes("unauthorized")) {
438
437
  return errorCodes.Auth;
@@ -440,9 +439,6 @@ function mapErrorToCode(error) {
440
439
  if (message.includes("validation") || message.includes("invalid") || message.includes("required") || message.includes("positive integer")) {
441
440
  return errorCodes.Validation;
442
441
  }
443
- if (message.includes("not found") || message.includes(" 404")) {
444
- return errorCodes.NotFound;
445
- }
446
442
  return errorCodes.Unknown;
447
443
  }
448
444
 
@@ -1362,7 +1358,7 @@ function isCheckPassBucket(bucket) {
1362
1358
  }
1363
1359
  return normalized === "pass";
1364
1360
  }
1365
- function normalizeCliData(capabilityId, data, params) {
1361
+ function normalizeCliData(capabilityId, data, params, context) {
1366
1362
  const normalizeRelease = (input) => {
1367
1363
  if (typeof input !== "object" || input === null || Array.isArray(input)) {
1368
1364
  return {
@@ -1567,7 +1563,7 @@ function normalizeCliData(capabilityId, data, params) {
1567
1563
  };
1568
1564
  }
1569
1565
  if (capabilityId === "pr.checks.rerun_failed" || capabilityId === "pr.checks.rerun_all") {
1570
- const effectiveMode = params.__effectiveRerunMode === "all" ? "all" : capabilityId === "pr.checks.rerun_failed" ? "failed" : "all";
1566
+ const effectiveMode = context?.effectiveRerunMode === "all" ? "all" : capabilityId === "pr.checks.rerun_failed" ? "failed" : "all";
1571
1567
  return {
1572
1568
  prNumber: Number(params.prNumber),
1573
1569
  runId: Number(params.runId),
@@ -1880,7 +1876,7 @@ function normalizeCliData(capabilityId, data, params) {
1880
1876
  const release = normalizeRelease(data);
1881
1877
  return {
1882
1878
  ...release,
1883
- wasDraft: Boolean(params.__wasDraft)
1879
+ wasDraft: Boolean(context?.wasDraft)
1884
1880
  };
1885
1881
  }
1886
1882
  if (capabilityId === "workflow_dispatch.run") {
@@ -1956,9 +1952,8 @@ async function runCliCapability(runner, capabilityId, params, card) {
1956
1952
  { capabilityId, reason: "CARD_FALLBACK" }
1957
1953
  );
1958
1954
  }
1959
- const normalized2 = normalizeCliData(capabilityId, parseCliData(result2.stdout), {
1960
- ...params,
1961
- __wasDraft: true
1955
+ const normalized2 = normalizeCliData(capabilityId, parseCliData(result2.stdout), params, {
1956
+ wasDraft: true
1962
1957
  });
1963
1958
  return normalizeResult(normalized2, "cli", { capabilityId, reason: "CARD_FALLBACK" });
1964
1959
  }
@@ -1971,9 +1966,8 @@ async function runCliCapability(runner, capabilityId, params, card) {
1971
1966
  const rerunAllResult = await runner.run("gh", rerunAllArgs, DEFAULT_TIMEOUT_MS);
1972
1967
  if (rerunAllResult.exitCode === 0) {
1973
1968
  const rerunData = NON_JSON_STDOUT_CAPABILITIES.has(capabilityId) ? {} : parseCliData(rerunAllResult.stdout);
1974
- const fallbackData = normalizeCliData(capabilityId, rerunData, {
1975
- ...params,
1976
- __effectiveRerunMode: "all"
1969
+ const fallbackData = normalizeCliData(capabilityId, rerunData, params, {
1970
+ effectiveRerunMode: "all"
1977
1971
  });
1978
1972
  return normalizeResult(fallbackData, "cli", { capabilityId, reason: "CARD_FALLBACK" });
1979
1973
  }
@@ -2271,7 +2265,7 @@ function preflightCheck(input) {
2271
2265
  if (input.route === "cli" && input.ghCliAvailable === false) {
2272
2266
  return {
2273
2267
  ok: false,
2274
- code: errorCodes.Validation,
2268
+ code: errorCodes.AdapterUnsupported,
2275
2269
  message: "GitHub CLI is required for cli route",
2276
2270
  retryable: false,
2277
2271
  details: { route: input.route }
@@ -2305,9 +2299,6 @@ function preflightCheck(input) {
2305
2299
  var routePreferenceOrder = ["cli", "graphql"];
2306
2300
 
2307
2301
  // src/core/routing/engine.ts
2308
- function chooseRoute() {
2309
- return routePreferenceOrder[0];
2310
- }
2311
2302
  var DEFAULT_REASON = "DEFAULT_POLICY";
2312
2303
  var CLI_ENV_CACHE_TTL_MS = 3e4;
2313
2304
  var cliEnvironmentCache = /* @__PURE__ */ new WeakMap();
@@ -2368,7 +2359,7 @@ async function executeTask(request, deps) {
2368
2359
  message: `Unsupported task: ${request.task}`,
2369
2360
  retryable: false
2370
2361
  },
2371
- chooseRoute(),
2362
+ routePreferenceOrder[0],
2372
2363
  { capabilityId: request.task, reason }
2373
2364
  );
2374
2365
  }
@@ -4145,4 +4136,4 @@ export {
4145
4136
  createGithubClientFromToken,
4146
4137
  createGithubClient
4147
4138
  };
4148
- //# sourceMappingURL=chunk-PJ2JKKQE.js.map
4139
+ //# sourceMappingURL=chunk-RDUPMVHG.js.map