pi-ghwebhook 0.1.0 → 0.2.0

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.
@@ -0,0 +1,122 @@
1
+ export function globMatch(pattern, text) {
2
+ if (pattern === text || pattern === "*")
3
+ return true;
4
+ const escaped = pattern
5
+ .replace(/[.+^${}()|[\]\\]/g, "\\$&")
6
+ .replace(/\*\*/g, ".*")
7
+ .replace(/\*/g, ".*");
8
+ const regex = new RegExp(`^${escaped}$`);
9
+ return regex.test(text);
10
+ }
11
+ export function resolvePayloadBranch(payload) {
12
+ return (payload.workflow_run?.head_branch ??
13
+ payload.pull_request?.head?.ref ??
14
+ payload.check_suite?.head_branch ??
15
+ payload.workflow_job?.head_branch ??
16
+ (typeof payload.ref === "string"
17
+ ? payload.ref.replace("refs/heads/", "")
18
+ : undefined));
19
+ }
20
+ function matchBranches(branches, actualBranch, currentBranch) {
21
+ for (const pattern of branches) {
22
+ if (pattern === "@current" && actualBranch === currentBranch) {
23
+ return true;
24
+ }
25
+ if (globMatch(pattern, actualBranch)) {
26
+ return true;
27
+ }
28
+ }
29
+ return false;
30
+ }
31
+ function matchTypes(types, action) {
32
+ if (!Array.isArray(types) || types.length === 0)
33
+ return true;
34
+ const actionStr = typeof action === "string" ? action : "";
35
+ return types.includes(actionStr);
36
+ }
37
+ function matchBranchFilter(branches, payload, currentBranch) {
38
+ if (!Array.isArray(branches) || branches.length === 0)
39
+ return true;
40
+ const actualBranch = resolvePayloadBranch(payload);
41
+ return Boolean(actualBranch && matchBranches(branches, actualBranch, currentBranch));
42
+ }
43
+ function matchWorkflows(workflows, payload) {
44
+ if (!Array.isArray(workflows) || workflows.length === 0)
45
+ return true;
46
+ const workflowName = payload.workflow_run?.name ?? payload.workflow_job?.workflow_name ?? "";
47
+ return workflows.some((w) => globMatch(w, workflowName));
48
+ }
49
+ export function isTriggerMatched(trigger, payload, currentBranch) {
50
+ if (!trigger)
51
+ return true;
52
+ return (matchTypes(trigger.types, payload.action) &&
53
+ matchBranchFilter(trigger.branches, payload, currentBranch) &&
54
+ matchWorkflows(trigger.workflows, payload));
55
+ }
56
+ function getNestedValue(obj, path) {
57
+ const parts = path.split(".");
58
+ let current = obj;
59
+ for (const part of parts) {
60
+ if (current == null || typeof current !== "object")
61
+ return undefined;
62
+ current = current[part];
63
+ }
64
+ return current;
65
+ }
66
+ function resolveContextValue(path, payload, currentBranch) {
67
+ const cleanPath = path
68
+ .replace(/^github\.event\./, "")
69
+ .replace(/^event\./, "")
70
+ .trim();
71
+ // Special shortcuts
72
+ if (cleanPath === "branch")
73
+ return resolvePayloadBranch(payload) ?? currentBranch;
74
+ if (cleanPath === "conclusion")
75
+ return payload.workflow_run?.conclusion ?? payload.check_suite?.conclusion;
76
+ if (cleanPath === "sender")
77
+ return payload.sender?.login ?? payload.review?.user?.login;
78
+ if (cleanPath === "isBot") {
79
+ const senderType = payload.review?.user?.type ?? payload.sender?.type;
80
+ const login = payload.review?.user?.login ?? payload.sender?.login ?? "";
81
+ return senderType === "Bot" || login.endsWith("[bot]");
82
+ }
83
+ return getNestedValue(payload, cleanPath);
84
+ }
85
+ function parseLiteral(literal) {
86
+ const trimmed = literal.trim();
87
+ if (trimmed === "true")
88
+ return true;
89
+ if (trimmed === "false")
90
+ return false;
91
+ if (trimmed === "null")
92
+ return null;
93
+ if (/^['"].*['"]$/.test(trimmed)) {
94
+ return trimmed.slice(1, -1);
95
+ }
96
+ const num = Number(trimmed);
97
+ if (!Number.isNaN(num))
98
+ return num;
99
+ return trimmed;
100
+ }
101
+ export function evaluateCondition(expr, payload, currentBranch) {
102
+ if (!expr || !expr.trim())
103
+ return true;
104
+ const match = expr.match(/^(.+?)\s*(===|!==|==|!=)\s*(.+)$/);
105
+ if (!match) {
106
+ const val = resolveContextValue(expr.trim(), payload, currentBranch);
107
+ return Boolean(val);
108
+ }
109
+ const [, leftRaw, op, rightRaw] = match;
110
+ const leftVal = resolveContextValue(leftRaw.trim(), payload, currentBranch);
111
+ const rightVal = parseLiteral(rightRaw.trim());
112
+ const isEqualOp = op === "==" || op === "===";
113
+ if (typeof rightVal === "string" &&
114
+ typeof leftVal === "string" &&
115
+ rightVal.includes("*")) {
116
+ const matchesGlob = globMatch(rightVal, leftVal);
117
+ return isEqualOp ? matchesGlob : !matchesGlob;
118
+ }
119
+ const areEqual = leftVal === rightVal;
120
+ return isEqualOp ? areEqual : !areEqual;
121
+ }
122
+ //# sourceMappingURL=matcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matcher.js","sourceRoot":"","sources":["../../src/bus/matcher.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,IAAY;IACrD,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO;SACpB,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;SACpC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;SACtB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACxB,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,OAAuB;IAEvB,OAAO,CACL,OAAO,CAAC,YAAY,EAAE,WAAW;QACjC,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG;QAC/B,OAAO,CAAC,WAAW,EAAE,WAAW;QAChC,OAAO,CAAC,YAAY,EAAE,WAAW;QACjC,CAAC,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ;YAC9B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;YACxC,CAAC,CAAC,SAAS,CAAC,CACf,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,QA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GhWebhookWorkflow } from "../types/schema.js";
2
+ export declare function loadProjectConfig(cwd: string): Promise<GhWebhookWorkflow | null>;
3
3
  export declare function resolveGitBranch(cwd: string): Promise<string>;
4
4
  export declare function parseGitHubRepo(remoteUrl: string): string | null;
5
5
  export declare function resolveGitRepo(cwd: string): Promise<string | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAmB1D,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAmBjC;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWnE;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOhE;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxE"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAmB5D,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAmBnC;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWnE;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOhE;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxE"}
@@ -24,7 +24,7 @@ export async function loadProjectConfig(cwd) {
24
24
  try {
25
25
  const content = await readFile(fullPath, "utf8");
26
26
  const parsed = JSON.parse(content);
27
- if (parsed && typeof parsed === "object" && parsed.version === 1) {
27
+ if (parsed && typeof parsed === "object" && parsed.on && parsed.jobs) {
28
28
  return parsed;
29
29
  }
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,iBAAiB,GAAG;IACxB,oBAAoB;IACpB,wBAAwB;IACxB,gBAAgB;CACjB,CAAC;AAEF,KAAK,UAAU,UAAU,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAW;IAEX,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACpC,IAAI,MAAM,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;gBACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAoB,CAAC;gBACtD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,C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AY,GAAG,IAAI,CA+FjE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAUpE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAgGjE"}
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ export default function ghWebhookExtension(pi) {
22
22
  pi.on("session_start", async (_event, ctx) => {
23
23
  // 1. 工作区探测:若当前项目无 .pi/ghwebhook.json,则静默休眠,零资源占用
24
24
  const config = await loadProjectConfig(ctx.cwd);
25
- if (!config || !config.enabled) {
25
+ if (!config) {
26
26
  return;
27
27
  }
28
28
  // 2. 解析当前 Git 分支与远端仓库
@@ -36,8 +36,8 @@ export default function ghWebhookExtension(pi) {
36
36
  }
37
37
  return;
38
38
  }
39
- // 3. 构建表驱动事件总线
40
- const bus = new WebhookEventBus(config.subscriptions);
39
+ // 3. 构建 GitHub Actions Workflow 事件总线
40
+ const bus = new WebhookEventBus(config);
41
41
  // 4. 启动随机端口本地回环服务器
42
42
  loopback = new LoopbackServer({
43
43
  secret: config.secret,
@@ -60,7 +60,7 @@ export default function ghWebhookExtension(pi) {
60
60
  }
61
61
  return;
62
62
  }
63
- // 5. 托管 gh webhook forward 长连接子进程(默认全量监听 --events=*)
63
+ // 5. 托管 gh webhook forward 长连接子进程(全量监听)
64
64
  forwarder = new GhForwarder({
65
65
  repo,
66
66
  url: loopback.getUrl(),
@@ -71,7 +71,8 @@ export default function ghWebhookExtension(pi) {
71
71
  });
72
72
  forwarder.start();
73
73
  if (ctx.hasUI) {
74
- ctx.ui.notify(`[pi-ghwebhook] 已监听 ${repo} (${currentBranch}) GitHub 事件流 (端口: ${loopback.getPort()})`, "info");
74
+ const displayName = config.name ? `[${config.name}]` : "[pi-ghwebhook]";
75
+ ctx.ui.notify(`${displayName} 已监听 ${repo} (${currentBranch}) 事件流 (端口: ${loopback.getPort()})`, "info");
75
76
  }
76
77
  });
77
78
  pi.on("session_shutdown", async () => {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAgB;IACzD,IAAI,QAAQ,GAA0B,IAAI,CAAC;IAC3C,IAAI,SAAS,GAAuB,IAAI,CAAC;IAEzC,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;QACzB,IAAI,SAAS,EAAE,CAAC;YACd,SAAS,CAAC,IAAI,EAAE,CAAC;YACjB,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC;QACD,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACtB,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;QACxB,IAAI,SAAS;YAAE,SAAS,CAAC,IAAI,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC3C,iDAAiD;QACjD,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QAED,sBAAsB;QACtB,MAAM,aAAa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C,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,OAAO,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,59 +1,33 @@
1
1
  import { Type, type Static } from "typebox";
2
- export declare const FilterSchema: Type.TObject<{
3
- branch: Type.TOptional<Type.TString>;
4
- conclusion: Type.TOptional<Type.TString>;
5
- workflow: Type.TOptional<Type.TString>;
6
- state: Type.TOptional<Type.TString>;
7
- senders: Type.TOptional<Type.TArray<Type.TString>>;
8
- isBot: Type.TOptional<Type.TBoolean>;
9
- match: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean]>>>;
2
+ export declare const EventTriggerSchema: Type.TObject<{
3
+ types: Type.TOptional<Type.TArray<Type.TString>>;
4
+ branches: Type.TOptional<Type.TArray<Type.TString>>;
5
+ workflows: Type.TOptional<Type.TArray<Type.TString>>;
10
6
  }>;
11
- export type FilterConfig = Static<typeof FilterSchema>;
12
- export declare const ActionSchema: Type.TObject<{
7
+ export type EventTriggerConfig = Static<typeof EventTriggerSchema>;
8
+ export declare const JobSchema: Type.TObject<{
9
+ name: Type.TOptional<Type.TString>;
10
+ if: Type.TOptional<Type.TString>;
13
11
  prompt: Type.TString;
14
12
  deliverAs: Type.TOptional<Type.TUnion<[Type.TLiteral<"steer">, Type.TLiteral<"followUp">]>>;
15
13
  }>;
16
- export type ActionConfig = Static<typeof ActionSchema>;
17
- export declare const SubscriptionRuleSchema: Type.TObject<{
18
- event: Type.TOptional<Type.TString>;
19
- topic: Type.TOptional<Type.TString>;
20
- filters: Type.TOptional<Type.TObject<{
21
- branch: Type.TOptional<Type.TString>;
22
- conclusion: Type.TOptional<Type.TString>;
23
- workflow: Type.TOptional<Type.TString>;
24
- state: Type.TOptional<Type.TString>;
25
- senders: Type.TOptional<Type.TArray<Type.TString>>;
26
- isBot: Type.TOptional<Type.TBoolean>;
27
- match: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean]>>>;
28
- }>>;
29
- action: Type.TObject<{
30
- prompt: Type.TString;
31
- deliverAs: Type.TOptional<Type.TUnion<[Type.TLiteral<"steer">, Type.TLiteral<"followUp">]>>;
32
- }>;
33
- }>;
34
- export type SubscriptionRule = Static<typeof SubscriptionRuleSchema>;
35
- export declare const ConfigSchema: Type.TObject<{
36
- version: Type.TLiteral<1>;
37
- enabled: Type.TBoolean;
14
+ export type JobConfig = Static<typeof JobSchema>;
15
+ export declare const WorkflowSchema: Type.TObject<{
16
+ $schema: Type.TOptional<Type.TString>;
17
+ name: Type.TOptional<Type.TString>;
38
18
  repo: Type.TOptional<Type.TString>;
39
19
  secret: Type.TOptional<Type.TString>;
40
- subscriptions: Type.TArray<Type.TObject<{
41
- event: Type.TOptional<Type.TString>;
42
- topic: Type.TOptional<Type.TString>;
43
- filters: Type.TOptional<Type.TObject<{
44
- branch: Type.TOptional<Type.TString>;
45
- conclusion: Type.TOptional<Type.TString>;
46
- workflow: Type.TOptional<Type.TString>;
47
- state: Type.TOptional<Type.TString>;
48
- senders: Type.TOptional<Type.TArray<Type.TString>>;
49
- isBot: Type.TOptional<Type.TBoolean>;
50
- match: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean]>>>;
51
- }>>;
52
- action: Type.TObject<{
53
- prompt: Type.TString;
54
- deliverAs: Type.TOptional<Type.TUnion<[Type.TLiteral<"steer">, Type.TLiteral<"followUp">]>>;
55
- }>;
20
+ on: Type.TUnion<[Type.TString, Type.TArray<Type.TString>, Type.TRecord<"^.*$", Type.TUnion<[Type.TNull, Type.TObject<{
21
+ types: Type.TOptional<Type.TArray<Type.TString>>;
22
+ branches: Type.TOptional<Type.TArray<Type.TString>>;
23
+ workflows: Type.TOptional<Type.TArray<Type.TString>>;
24
+ }>]>>]>;
25
+ jobs: Type.TRecord<"^.*$", Type.TObject<{
26
+ name: Type.TOptional<Type.TString>;
27
+ if: Type.TOptional<Type.TString>;
28
+ prompt: Type.TString;
29
+ deliverAs: Type.TOptional<Type.TUnion<[Type.TLiteral<"steer">, Type.TLiteral<"followUp">]>>;
56
30
  }>>;
57
31
  }>;
58
- export type GhWebhookConfig = Static<typeof ConfigSchema>;
32
+ export type GhWebhookWorkflow = Static<typeof WorkflowSchema>;
59
33
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,YAAY;;;;;;;;EAuCxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,eAAO,MAAM,YAAY;;;EAaxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;EAkBlC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAErE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;EAkBxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,kBAAkB;;;;EAe9B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEnE,eAAO,MAAM,SAAS;;;;;EAkBrB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEjD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;EA2B1B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -1,49 +1,35 @@
1
1
  import { Type } from "typebox";
2
- export const FilterSchema = Type.Object({
3
- branch: Type.Optional(Type.String({ description: "Target branch name or '@current'" })),
4
- conclusion: Type.Optional(Type.String({
5
- description: "Conclusion filter (e.g. 'failure', 'success')",
6
- })),
7
- workflow: Type.Optional(Type.String({ description: "Workflow name filter (e.g. 'CI')" })),
8
- state: Type.Optional(Type.String({
9
- description: "Review or PR state filter (e.g. 'changes_requested', 'approved')",
10
- })),
11
- senders: Type.Optional(Type.Array(Type.String(), { description: "Allowed sender logins" })),
12
- isBot: Type.Optional(Type.Boolean({
13
- description: "Filter for bot (true) or human (false) senders",
14
- })),
15
- match: Type.Optional(Type.Record(Type.String(), Type.Union([Type.String(), Type.Number(), Type.Boolean()]), {
16
- description: "Arbitrary field matching on payload (dot-separated path)",
17
- })),
18
- }, { additionalProperties: false });
19
- export const ActionSchema = Type.Object({
20
- prompt: Type.String({
21
- description: "Template string to dispatch to agent",
22
- }),
2
+ export const EventTriggerSchema = Type.Object({
3
+ types: Type.Optional(Type.Array(Type.String(), { description: "Event activity types" })),
4
+ branches: Type.Optional(Type.Array(Type.String(), {
5
+ description: "Branch filters, supports '@current' and globs",
6
+ })),
7
+ workflows: Type.Optional(Type.Array(Type.String(), { description: "Workflow names filter" })),
8
+ }, { additionalProperties: true });
9
+ export const JobSchema = Type.Object({
10
+ name: Type.Optional(Type.String({ description: "Optional job name" })),
11
+ if: Type.Optional(Type.String({
12
+ description: "Condition expression (e.g. \"conclusion == 'failure'\")",
13
+ })),
14
+ prompt: Type.String({ description: "Template string sent to Pi Agent" }),
23
15
  deliverAs: Type.Optional(Type.Union([Type.Literal("steer"), Type.Literal("followUp")], {
24
16
  description: "Delivery urgency: steer interrupts turn, followUp queues next",
17
+ default: "followUp",
25
18
  })),
26
19
  }, { additionalProperties: false });
27
- export const SubscriptionRuleSchema = Type.Object({
28
- event: Type.Optional(Type.String({
29
- description: "Upstream GitHub Webhook event identifier (e.g. 'workflow_run.completed', 'push', 'issues.opened')",
30
- })),
31
- topic: Type.Optional(Type.String({
32
- description: "Alias for 'event' (e.g. 'workflow_run.completed' or 'github.workflow_run.completed')",
33
- })),
34
- filters: Type.Optional(FilterSchema),
35
- action: ActionSchema,
36
- }, { additionalProperties: false });
37
- export const ConfigSchema = Type.Object({
38
- version: Type.Literal(1, { description: "Schema version" }),
39
- enabled: Type.Boolean({ default: true }),
20
+ export const WorkflowSchema = Type.Object({
21
+ $schema: Type.Optional(Type.String()),
22
+ name: Type.Optional(Type.String({ description: "Workflow display name" })),
40
23
  repo: Type.Optional(Type.String({
41
24
  default: "auto",
42
25
  description: "Target GitHub repo (owner/repo or 'auto')",
43
26
  })),
44
27
  secret: Type.Optional(Type.String({ description: "Optional Webhook HMAC secret" })),
45
- subscriptions: Type.Array(SubscriptionRuleSchema, {
46
- description: "List of declarative webhook event subscriptions",
47
- }),
28
+ on: Type.Union([
29
+ Type.String(),
30
+ Type.Array(Type.String()),
31
+ Type.Record(Type.String(), Type.Union([Type.Null(), EventTriggerSchema])),
32
+ ], { description: "GitHub event triggers specification" }),
33
+ jobs: Type.Record(Type.String(), JobSchema, { description: "Jobs map" }),
48
34
  }, { additionalProperties: false });
49
35
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CACrC;IACE,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC,CACjE;IACD,UAAU,EAA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O,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAC1E,IAAI,EAAE,IAAI,CAAC,QAAQ,CACjB,IAAI,CAAC,MAAM,CAAC;QACV,OAAO,EAAE,MAAM;QACf,WAAW,EAAE,2CAA2C;KACzD,CAAC,CACH;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC,CAC7D;IACD,EAAE,EAAE,IAAI,CAAC,KAAK,CACZ;QACE,IAAI,CAAC,MAAM,EAAE;QACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CACT,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAC9C;KACF,EACD,EAAE,WAAW,EAAE,qCAAqC,EAAE,CACvD;IACD,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;CACzE,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ghwebhook",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Universal GitHub Webhook event bus and wake-up engine for Pi coding agent",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -29,6 +29,8 @@
29
29
  "files": [
30
30
  "dist",
31
31
  "src",
32
+ "skills",
33
+ "schemas",
32
34
  "README.md",
33
35
  "README_zh.md",
34
36
  "CHANGELOG.md",
@@ -61,6 +63,9 @@
61
63
  "pi": {
62
64
  "extensions": [
63
65
  "./dist/index.js"
66
+ ],
67
+ "skills": [
68
+ "./skills"
64
69
  ]
65
70
  }
66
71
  }