@elnora-ai/linear 1.0.1 → 2.0.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.
- package/.claude-plugin/marketplace.json +7 -2
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +25 -1
- package/README.md +275 -25
- package/agents/linear-issue-creator.md +135 -17
- package/agents/linear-issue-reviewer.md +122 -23
- package/agents/linear-issue-updater.md +137 -25
- package/agents/linear-state-curator.md +173 -0
- package/agents/linear-url-to-issues.md +190 -26
- package/commands/linear-cleanup.md +64 -29
- package/dist/cli.js +69 -1
- package/dist/cli.js.map +1 -1
- package/dist/client/auth.d.ts +10 -0
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +50 -3
- package/dist/client/auth.js.map +1 -1
- package/dist/client/linear-client.d.ts +7 -0
- package/dist/client/linear-client.d.ts.map +1 -1
- package/dist/client/linear-client.js +13 -1
- package/dist/client/linear-client.js.map +1 -1
- package/dist/commands/agent-activities.d.ts +3 -0
- package/dist/commands/agent-activities.d.ts.map +1 -0
- package/dist/commands/agent-activities.js +144 -0
- package/dist/commands/agent-activities.js.map +1 -0
- package/dist/commands/agent-sessions.d.ts +3 -0
- package/dist/commands/agent-sessions.d.ts.map +1 -0
- package/dist/commands/agent-sessions.js +132 -0
- package/dist/commands/agent-sessions.js.map +1 -0
- package/dist/commands/attachments.d.ts +3 -0
- package/dist/commands/attachments.d.ts.map +1 -0
- package/dist/commands/attachments.js +265 -0
- package/dist/commands/attachments.js.map +1 -0
- package/dist/commands/audit.d.ts +3 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +73 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/comments.d.ts +3 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +107 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/completion.d.ts +3 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +62 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/context.d.ts +3 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +94 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/curator.d.ts +14 -0
- package/dist/commands/curator.d.ts.map +1 -1
- package/dist/commands/curator.js +97 -19
- package/dist/commands/curator.js.map +1 -1
- package/dist/commands/customer-needs.d.ts +3 -0
- package/dist/commands/customer-needs.d.ts.map +1 -0
- package/dist/commands/customer-needs.js +198 -0
- package/dist/commands/customer-needs.js.map +1 -0
- package/dist/commands/customers.d.ts +5 -0
- package/dist/commands/customers.d.ts.map +1 -0
- package/dist/commands/customers.js +201 -0
- package/dist/commands/customers.js.map +1 -0
- package/dist/commands/cycles.d.ts +3 -0
- package/dist/commands/cycles.d.ts.map +1 -0
- package/dist/commands/cycles.js +67 -0
- package/dist/commands/cycles.js.map +1 -0
- package/dist/commands/documents.d.ts +3 -0
- package/dist/commands/documents.d.ts.map +1 -0
- package/dist/commands/documents.js +105 -0
- package/dist/commands/documents.js.map +1 -0
- package/dist/commands/favorites.d.ts +3 -0
- package/dist/commands/favorites.d.ts.map +1 -0
- package/dist/commands/favorites.js +101 -0
- package/dist/commands/favorites.js.map +1 -0
- package/dist/commands/index.d.ts +30 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +30 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/initiatives.d.ts +3 -0
- package/dist/commands/initiatives.d.ts.map +1 -0
- package/dist/commands/initiatives.js +106 -0
- package/dist/commands/initiatives.js.map +1 -0
- package/dist/commands/issues.d.ts +21 -0
- package/dist/commands/issues.d.ts.map +1 -0
- package/dist/commands/issues.js +1083 -0
- package/dist/commands/issues.js.map +1 -0
- package/dist/commands/labels.d.ts +3 -0
- package/dist/commands/labels.d.ts.map +1 -0
- package/dist/commands/labels.js +111 -0
- package/dist/commands/labels.js.map +1 -0
- package/dist/commands/milestones.d.ts +3 -0
- package/dist/commands/milestones.d.ts.map +1 -0
- package/dist/commands/milestones.js +94 -0
- package/dist/commands/milestones.js.map +1 -0
- package/dist/commands/notifications.d.ts +3 -0
- package/dist/commands/notifications.d.ts.map +1 -0
- package/dist/commands/notifications.js +130 -0
- package/dist/commands/notifications.js.map +1 -0
- package/dist/commands/project-labels.d.ts +3 -0
- package/dist/commands/project-labels.d.ts.map +1 -0
- package/dist/commands/project-labels.js +80 -0
- package/dist/commands/project-labels.js.map +1 -0
- package/dist/commands/project-relations.d.ts +3 -0
- package/dist/commands/project-relations.d.ts.map +1 -0
- package/dist/commands/project-relations.js +96 -0
- package/dist/commands/project-relations.js.map +1 -0
- package/dist/commands/projects.d.ts +3 -0
- package/dist/commands/projects.d.ts.map +1 -0
- package/dist/commands/projects.js +263 -0
- package/dist/commands/projects.js.map +1 -0
- package/dist/commands/quota.d.ts +3 -0
- package/dist/commands/quota.d.ts.map +1 -0
- package/dist/commands/quota.js +28 -0
- package/dist/commands/quota.js.map +1 -0
- package/dist/commands/reactions.d.ts +7 -0
- package/dist/commands/reactions.d.ts.map +1 -0
- package/dist/commands/reactions.js +53 -0
- package/dist/commands/reactions.js.map +1 -0
- package/dist/commands/relations.d.ts +3 -0
- package/dist/commands/relations.d.ts.map +1 -0
- package/dist/commands/relations.js +73 -0
- package/dist/commands/relations.js.map +1 -0
- package/dist/commands/states.d.ts +3 -0
- package/dist/commands/states.d.ts.map +1 -0
- package/dist/commands/states.js +52 -0
- package/dist/commands/states.js.map +1 -0
- package/dist/commands/status-updates.d.ts +3 -0
- package/dist/commands/status-updates.d.ts.map +1 -0
- package/dist/commands/status-updates.js +117 -0
- package/dist/commands/status-updates.js.map +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +58 -18
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/teams.d.ts +3 -0
- package/dist/commands/teams.d.ts.map +1 -0
- package/dist/commands/teams.js +135 -0
- package/dist/commands/teams.js.map +1 -0
- package/dist/commands/templates.d.ts +3 -0
- package/dist/commands/templates.d.ts.map +1 -0
- package/dist/commands/templates.js +76 -0
- package/dist/commands/templates.js.map +1 -0
- package/dist/commands/users.d.ts +3 -0
- package/dist/commands/users.d.ts.map +1 -0
- package/dist/commands/users.js +40 -0
- package/dist/commands/users.js.map +1 -0
- package/dist/commands/views.d.ts +3 -0
- package/dist/commands/views.d.ts.map +1 -0
- package/dist/commands/views.js +177 -0
- package/dist/commands/views.js.map +1 -0
- package/dist/commands/webhooks.d.ts +3 -0
- package/dist/commands/webhooks.d.ts.map +1 -0
- package/dist/commands/webhooks.js +234 -0
- package/dist/commands/webhooks.js.map +1 -0
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +3 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/types.d.ts +15 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +1 -0
- package/dist/config/types.js.map +1 -1
- package/dist/curator/dispatch.d.ts +52 -0
- package/dist/curator/dispatch.d.ts.map +1 -0
- package/dist/curator/dispatch.js +144 -0
- package/dist/curator/dispatch.js.map +1 -0
- package/dist/curator/index.d.ts +5 -0
- package/dist/curator/index.d.ts.map +1 -0
- package/dist/curator/index.js +5 -0
- package/dist/curator/index.js.map +1 -0
- package/dist/curator/llm.d.ts +70 -0
- package/dist/curator/llm.d.ts.map +1 -0
- package/dist/curator/llm.js +107 -0
- package/dist/curator/llm.js.map +1 -0
- package/dist/curator/snapshot.d.ts +34 -0
- package/dist/curator/snapshot.d.ts.map +1 -0
- package/dist/curator/snapshot.js +127 -0
- package/dist/curator/snapshot.js.map +1 -0
- package/dist/curator/state.d.ts +50 -0
- package/dist/curator/state.d.ts.map +1 -0
- package/dist/curator/state.js +125 -0
- package/dist/curator/state.js.map +1 -0
- package/dist/lib/bulk-graphql.d.ts +144 -0
- package/dist/lib/bulk-graphql.d.ts.map +1 -0
- package/dist/lib/bulk-graphql.js +380 -0
- package/dist/lib/bulk-graphql.js.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/output/cli.d.ts +17 -0
- package/dist/output/cli.d.ts.map +1 -0
- package/dist/output/cli.js +252 -0
- package/dist/output/cli.js.map +1 -0
- package/dist/output/formatter.d.ts +6 -0
- package/dist/output/formatter.d.ts.map +1 -1
- package/dist/output/formatter.js +10 -0
- package/dist/output/formatter.js.map +1 -1
- package/dist/output/index.d.ts +1 -0
- package/dist/output/index.d.ts.map +1 -1
- package/dist/output/index.js +1 -0
- package/dist/output/index.js.map +1 -1
- package/dist/scripts/sync-linear-templates.d.ts +26 -0
- package/dist/scripts/sync-linear-templates.d.ts.map +1 -0
- package/dist/scripts/sync-linear-templates.js +115 -0
- package/dist/scripts/sync-linear-templates.js.map +1 -0
- package/dist/signals/github-commits.d.ts +31 -0
- package/dist/signals/github-commits.d.ts.map +1 -0
- package/dist/signals/github-commits.js +127 -0
- package/dist/signals/github-commits.js.map +1 -0
- package/dist/signals/github-pr.d.ts +16 -0
- package/dist/signals/github-pr.d.ts.map +1 -0
- package/dist/signals/github-pr.js +98 -0
- package/dist/signals/github-pr.js.map +1 -0
- package/dist/signals/index.d.ts +4 -0
- package/dist/signals/index.d.ts.map +1 -1
- package/dist/signals/index.js +4 -0
- package/dist/signals/index.js.map +1 -1
- package/dist/signals/linear-issues.d.ts +20 -0
- package/dist/signals/linear-issues.d.ts.map +1 -0
- package/dist/signals/linear-issues.js +115 -0
- package/dist/signals/linear-issues.js.map +1 -0
- package/dist/signals/registry.d.ts +4 -3
- package/dist/signals/registry.d.ts.map +1 -1
- package/dist/signals/registry.js +33 -11
- package/dist/signals/registry.js.map +1 -1
- package/dist/signals/slack-messages.d.ts +20 -0
- package/dist/signals/slack-messages.d.ts.map +1 -0
- package/dist/signals/slack-messages.js +129 -0
- package/dist/signals/slack-messages.js.map +1 -0
- package/dist/utils/errors.d.ts +81 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +110 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/label-policy.d.ts +60 -0
- package/dist/utils/label-policy.d.ts.map +1 -0
- package/dist/utils/label-policy.js +103 -0
- package/dist/utils/label-policy.js.map +1 -0
- package/dist/utils/parse.d.ts +48 -0
- package/dist/utils/parse.d.ts.map +1 -0
- package/dist/utils/parse.js +133 -0
- package/dist/utils/parse.js.map +1 -0
- package/dist/utils/project-status.d.ts +6 -0
- package/dist/utils/project-status.d.ts.map +1 -0
- package/dist/utils/project-status.js +33 -0
- package/dist/utils/project-status.js.map +1 -0
- package/dist/utils/rate-limit.d.ts +24 -0
- package/dist/utils/rate-limit.d.ts.map +1 -0
- package/dist/utils/rate-limit.js +89 -0
- package/dist/utils/rate-limit.js.map +1 -0
- package/dist/utils/resolve.d.ts +84 -0
- package/dist/utils/resolve.d.ts.map +1 -0
- package/dist/utils/resolve.js +172 -0
- package/dist/utils/resolve.js.map +1 -0
- package/dist/utils/sleep.d.ts +2 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +4 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/webhook-verify.d.ts +42 -0
- package/dist/utils/webhook-verify.d.ts.map +1 -0
- package/dist/utils/webhook-verify.js +65 -0
- package/dist/utils/webhook-verify.js.map +1 -0
- package/package.json +7 -2
- package/references/agent-description-template.md +31 -0
- package/references/cli-reference.md +227 -0
- package/references/curator-tiering-rules.md +78 -0
- package/references/label-policy.example.json +37 -0
- package/references/label-policy.placeholder.json +6 -0
- package/references/settings-template.md +30 -0
- package/references/signal-sources.example.json +0 -8
- package/references/sla-reference.md +70 -0
- package/references/template-index.md +34 -0
- package/references/workspace-labels.md +124 -0
- package/references/workspace-projects.md +56 -0
- package/references/workspace-routing.md +58 -0
- package/schemas/label-policy.json +72 -0
- package/scripts/postinstall.mjs +195 -0
- package/skills/linear-workspace/SKILL.md +65 -4
- package/templates/ACC-PRO-provision.md +74 -0
- package/templates/ACC-PRV-privileged.md +66 -0
- package/templates/ACC-QTR-review.md +77 -0
- package/templates/ACC-REV-revoke.md +67 -0
- package/templates/AI-USE-capability.md +111 -0
- package/templates/AUD-CAP-corrective.md +89 -0
- package/templates/AUD-INT-internal.md +92 -0
- package/templates/AUD-MGT-management.md +110 -0
- package/templates/CHG-MAJ-major.md +110 -0
- package/templates/CHG-SIG-significant.md +83 -0
- package/templates/CHG-STD-standard.md +47 -0
- package/templates/LRN-DOC-lessons.md +75 -0
- package/templates/OPS-BCK-backup.md +99 -0
- package/templates/OPS-DAT-data-mod.md +98 -0
- package/templates/RCA-DOC-root-cause.md +105 -0
- package/templates/RSK-ASS-assessment.md +87 -0
- package/templates/RSK-VND-vendor.md +113 -0
- package/templates/SEC-INC-incident.md +76 -0
- package/templates/SEC-PEN-pentest.md +58 -0
- package/templates/SEC-VLN-vulnerability.md +69 -0
- package/templates/SLA-AVL-availability.md +86 -0
- package/templates/SLA-OPS-operational.md +70 -0
- package/templates/agent-server-template/README.md +88 -0
- package/templates/agent-server-template/server.example.ts +185 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-commits.js","sourceRoot":"","sources":["../../src/signals/github-commits.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,gFAAgF;AAChF,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,sBAAsB;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAKtC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AACnC,MAAM,qBAAqB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,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACxB,MAAM,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBACrD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACtB,OAAO,CAAC,IAAI,CAAC;wBACZ,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;wBACxB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;wBACtB,OAAO,EAAE;4BACR,IAAI,EAAE,IAAI;4BACV,GAAG,EAAE,GAAG,CAAC,GAAG;4BACZ,YAAY,EAAE,GAAG,CAAC,YAAY;4BAC9B,OAAO,EAAE,GAAG,CAAC,OAAO;yBACpB;wBACD,UAAU;qBACV,CAAC,CAAC;oBACH,SAAS;gBACV,CAAC;gBACD,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;oBACtB,OAAO,CAAC,IAAI,CAAC;wBACZ,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;wBACxB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;wBACtB,eAAe,EAAE,EAAE;wBACnB,OAAO,EAAE;4BACR,IAAI,EAAE,IAAI;4BACV,GAAG,EAAE,GAAG,CAAC,GAAG;4BACZ,YAAY,EAAE,GAAG,CAAC,YAAY;4BAC9B,OAAO,EAAE,GAAG,CAAC,OAAO;yBACpB;wBACD,UAAU;qBACV,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LinearConfig } from "../config/types.js";
|
|
2
|
+
import type { Signal, SignalSourceContext, SignalSourceImpl } from "./types.js";
|
|
3
|
+
export interface GithubPrConfig {
|
|
4
|
+
type: "github_pr";
|
|
5
|
+
name: string;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
repos?: string[];
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class GithubPrSource implements SignalSourceImpl {
|
|
11
|
+
readonly config: GithubPrConfig;
|
|
12
|
+
private readonly linearConfig;
|
|
13
|
+
constructor(config: GithubPrConfig, linearConfig: LinearConfig);
|
|
14
|
+
collect(ctx: SignalSourceContext): Promise<Signal[]>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=github-pr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-pr.d.ts","sourceRoot":"","sources":["../../src/signals/github-pr.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAOhF,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAYD,qBAAa,cAAe,YAAW,gBAAgB;IACtD,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;gBAEhC,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY;IAKxD,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAiF1D"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// `github_pr` signal source.
|
|
2
|
+
//
|
|
3
|
+
// Uses the GitHub CLI (`gh pr list`) to enumerate pull requests across the
|
|
4
|
+
// configured repos. Issue identifiers are extracted from PR title + body
|
|
5
|
+
// using the team-prefix regex derived from references/teams.json.
|
|
6
|
+
//
|
|
7
|
+
// Required: the `gh` CLI must be installed and authenticated (`gh auth status`).
|
|
8
|
+
// Without it, the source emits one warning signal and returns.
|
|
9
|
+
import { execFile } from "node:child_process";
|
|
10
|
+
import { promisify } from "node:util";
|
|
11
|
+
import { _internal as commitsInternal } from "./github-commits.js";
|
|
12
|
+
const runCmd = promisify(execFile);
|
|
13
|
+
const PR_LIMIT_DEFAULT = 100;
|
|
14
|
+
const MAX_BUFFER = 10_000_000;
|
|
15
|
+
const TIMEOUT_MS = 30_000;
|
|
16
|
+
export class GithubPrSource {
|
|
17
|
+
config;
|
|
18
|
+
linearConfig;
|
|
19
|
+
constructor(config, linearConfig) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.linearConfig = linearConfig;
|
|
22
|
+
}
|
|
23
|
+
async collect(ctx) {
|
|
24
|
+
const receivedAt = ctx.now.toISOString();
|
|
25
|
+
const teamKeys = this.linearConfig.teams.teams.map((t) => t.key);
|
|
26
|
+
const issueRegex = commitsInternal.buildTeamRegex(teamKeys);
|
|
27
|
+
const limit = this.config.limit ?? PR_LIMIT_DEFAULT;
|
|
28
|
+
const repoNames = this.config.repos ?? this.linearConfig.repos.repos.map((r) => r.name);
|
|
29
|
+
const reposByName = new Map(this.linearConfig.repos.repos.map((r) => [r.name, r]));
|
|
30
|
+
const signals = [];
|
|
31
|
+
for (const name of repoNames) {
|
|
32
|
+
const repo = reposByName.get(name);
|
|
33
|
+
if (!repo?.org) {
|
|
34
|
+
signals.push({
|
|
35
|
+
source: this.config.name,
|
|
36
|
+
type: this.config.type,
|
|
37
|
+
payload: { warning: `repo "${name}" has no org configured; skipped` },
|
|
38
|
+
receivedAt,
|
|
39
|
+
});
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const slug = `${repo.org}/${name}`;
|
|
43
|
+
let prs;
|
|
44
|
+
try {
|
|
45
|
+
const { stdout } = await runCmd("gh", [
|
|
46
|
+
"pr",
|
|
47
|
+
"list",
|
|
48
|
+
"--repo",
|
|
49
|
+
slug,
|
|
50
|
+
"--state",
|
|
51
|
+
"all",
|
|
52
|
+
"--limit",
|
|
53
|
+
String(limit),
|
|
54
|
+
"--json",
|
|
55
|
+
"number,title,body,state,mergedAt,author,url",
|
|
56
|
+
], { timeout: TIMEOUT_MS, maxBuffer: MAX_BUFFER });
|
|
57
|
+
prs = JSON.parse(stdout);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
signals.push({
|
|
61
|
+
source: this.config.name,
|
|
62
|
+
type: this.config.type,
|
|
63
|
+
payload: { warning: `gh pr list failed for "${slug}": ${err.message}` },
|
|
64
|
+
receivedAt,
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
for (const pr of prs) {
|
|
69
|
+
const haystack = `${pr.title}\n${pr.body ?? ""}`;
|
|
70
|
+
const ids = commitsInternal.extractIssueIds(haystack, issueRegex);
|
|
71
|
+
const payload = {
|
|
72
|
+
repo: name,
|
|
73
|
+
number: pr.number,
|
|
74
|
+
title: pr.title,
|
|
75
|
+
state: pr.state,
|
|
76
|
+
mergedAt: pr.mergedAt,
|
|
77
|
+
author: pr.author?.login ?? null,
|
|
78
|
+
url: pr.url,
|
|
79
|
+
};
|
|
80
|
+
if (ids.length === 0) {
|
|
81
|
+
signals.push({ source: this.config.name, type: this.config.type, payload, receivedAt });
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
for (const id of ids) {
|
|
85
|
+
signals.push({
|
|
86
|
+
source: this.config.name,
|
|
87
|
+
type: this.config.type,
|
|
88
|
+
issueIdentifier: id,
|
|
89
|
+
payload,
|
|
90
|
+
receivedAt,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return signals;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=github-pr.js.map
|
|
@@ -0,0 +1 @@
|
|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EAAE;wBACnB,OAAO;wBACP,UAAU;qBACV,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;CACD"}
|
package/dist/signals/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * from "./external-command.js";
|
|
2
|
+
export * from "./github-commits.js";
|
|
3
|
+
export * from "./github-pr.js";
|
|
4
|
+
export * from "./linear-issues.js";
|
|
2
5
|
export * from "./registry.js";
|
|
6
|
+
export * from "./slack-messages.js";
|
|
3
7
|
export * from "./types.js";
|
|
4
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signals/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signals/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
package/dist/signals/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * from "./external-command.js";
|
|
2
|
+
export * from "./github-commits.js";
|
|
3
|
+
export * from "./github-pr.js";
|
|
4
|
+
export * from "./linear-issues.js";
|
|
2
5
|
export * from "./registry.js";
|
|
6
|
+
export * from "./slack-messages.js";
|
|
3
7
|
export * from "./types.js";
|
|
4
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signals/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signals/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Signal, SignalSourceContext, SignalSourceImpl } from "./types.js";
|
|
2
|
+
export interface LinearIssuesConfig {
|
|
3
|
+
type: "linear_issues";
|
|
4
|
+
name: string;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
teams?: string[];
|
|
7
|
+
lookback_days?: number;
|
|
8
|
+
near_duplicate_threshold?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Jaccard similarity over whitespace-tokenised word sets.
|
|
12
|
+
* Cheap, language-agnostic, good enough for "did someone just file the same thing".
|
|
13
|
+
*/
|
|
14
|
+
export declare function titleSimilarity(a: string, b: string): number;
|
|
15
|
+
export declare class LinearIssuesSource implements SignalSourceImpl {
|
|
16
|
+
readonly config: LinearIssuesConfig;
|
|
17
|
+
constructor(config: LinearIssuesConfig);
|
|
18
|
+
collect(ctx: SignalSourceContext): Promise<Signal[]>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=linear-issues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linear-issues.d.ts","sourceRoot":"","sources":["../../src/signals/linear-issues.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAIhF,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAClC;AASD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAED,qBAAa,kBAAmB,YAAW,gBAAgB;IAC1D,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;gBAExB,MAAM,EAAE,kBAAkB;IAIhC,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAyE1D"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// `linear_issues` signal source.
|
|
2
|
+
//
|
|
3
|
+
// Cross-issue scanning against Linear itself. Surfaces title near-duplicates,
|
|
4
|
+
// issues that mention other issue IDs in description, and orphan candidates
|
|
5
|
+
// (no project, no assignee, no parent). Used by curator M5 (title near-dup)
|
|
6
|
+
// and H3 (duplicate-of-Done) class rules.
|
|
7
|
+
//
|
|
8
|
+
// Uses the bulk-graphql helper to keep round-trips low — one paginated query
|
|
9
|
+
// returns identifier + title + description + state.type + project + assignee
|
|
10
|
+
// + parent in a single GraphQL call.
|
|
11
|
+
import { bulkListIssues } from "../lib/bulk-graphql.js";
|
|
12
|
+
import { _internal as commitsInternal } from "./github-commits.js";
|
|
13
|
+
const DEFAULT_LOOKBACK_DAYS = 30;
|
|
14
|
+
function normaliseTitle(title) {
|
|
15
|
+
return title
|
|
16
|
+
.toLowerCase()
|
|
17
|
+
.replace(/[^\p{L}\p{N}]+/gu, " ")
|
|
18
|
+
.trim();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Jaccard similarity over whitespace-tokenised word sets.
|
|
22
|
+
* Cheap, language-agnostic, good enough for "did someone just file the same thing".
|
|
23
|
+
*/
|
|
24
|
+
export function titleSimilarity(a, b) {
|
|
25
|
+
const ta = new Set(normaliseTitle(a).split(/\s+/).filter(Boolean));
|
|
26
|
+
const tb = new Set(normaliseTitle(b).split(/\s+/).filter(Boolean));
|
|
27
|
+
if (ta.size === 0 || tb.size === 0)
|
|
28
|
+
return 0;
|
|
29
|
+
let inter = 0;
|
|
30
|
+
for (const t of ta)
|
|
31
|
+
if (tb.has(t))
|
|
32
|
+
inter++;
|
|
33
|
+
const union = ta.size + tb.size - inter;
|
|
34
|
+
return union === 0 ? 0 : inter / union;
|
|
35
|
+
}
|
|
36
|
+
export class LinearIssuesSource {
|
|
37
|
+
config;
|
|
38
|
+
constructor(config) {
|
|
39
|
+
this.config = config;
|
|
40
|
+
}
|
|
41
|
+
async collect(ctx) {
|
|
42
|
+
const receivedAt = ctx.now.toISOString();
|
|
43
|
+
const lookbackDays = this.config.lookback_days ?? DEFAULT_LOOKBACK_DAYS;
|
|
44
|
+
const threshold = this.config.near_duplicate_threshold ?? 0.7;
|
|
45
|
+
const cutoff = new Date(ctx.now.getTime() - lookbackDays * 24 * 3600 * 1000).toISOString();
|
|
46
|
+
const filter = { updatedAt: { gt: cutoff } };
|
|
47
|
+
if (this.config.teams && this.config.teams.length > 0) {
|
|
48
|
+
filter.team = { key: { in: this.config.teams } };
|
|
49
|
+
}
|
|
50
|
+
const nodes = await bulkListIssues(filter, { includeDescription: true, includeRelations: true });
|
|
51
|
+
const signals = [];
|
|
52
|
+
const teamKeys = [...new Set(nodes.map((n) => n.team?.key).filter((k) => Boolean(k)))];
|
|
53
|
+
const issueRegex = commitsInternal.buildTeamRegex(teamKeys);
|
|
54
|
+
const knownIds = new Set(nodes.map((n) => n.identifier));
|
|
55
|
+
for (const node of nodes) {
|
|
56
|
+
if (!node.description)
|
|
57
|
+
continue;
|
|
58
|
+
const refs = commitsInternal.extractIssueIds(node.description, issueRegex);
|
|
59
|
+
for (const ref of refs) {
|
|
60
|
+
if (ref === node.identifier)
|
|
61
|
+
continue;
|
|
62
|
+
if (!knownIds.has(ref))
|
|
63
|
+
continue;
|
|
64
|
+
signals.push({
|
|
65
|
+
source: this.config.name,
|
|
66
|
+
type: this.config.type,
|
|
67
|
+
issueIdentifier: node.identifier,
|
|
68
|
+
payload: { kind: "cross_reference", references: ref },
|
|
69
|
+
receivedAt,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
74
|
+
for (let j = i + 1; j < nodes.length; j++) {
|
|
75
|
+
const a = nodes[i];
|
|
76
|
+
const b = nodes[j];
|
|
77
|
+
if (a.team?.key !== b.team?.key)
|
|
78
|
+
continue;
|
|
79
|
+
const sim = titleSimilarity(a.title, b.title);
|
|
80
|
+
if (sim < threshold)
|
|
81
|
+
continue;
|
|
82
|
+
signals.push({
|
|
83
|
+
source: this.config.name,
|
|
84
|
+
type: this.config.type,
|
|
85
|
+
issueIdentifier: a.identifier,
|
|
86
|
+
payload: {
|
|
87
|
+
kind: "near_duplicate",
|
|
88
|
+
with: b.identifier,
|
|
89
|
+
similarity: Math.round(sim * 100) / 100,
|
|
90
|
+
},
|
|
91
|
+
receivedAt,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (const node of nodes) {
|
|
96
|
+
if (node.state?.type !== "unstarted" && node.state?.type !== "backlog")
|
|
97
|
+
continue;
|
|
98
|
+
if (node.project || node.assignee || node.parent)
|
|
99
|
+
continue;
|
|
100
|
+
signals.push({
|
|
101
|
+
source: this.config.name,
|
|
102
|
+
type: this.config.type,
|
|
103
|
+
issueIdentifier: node.identifier,
|
|
104
|
+
payload: {
|
|
105
|
+
kind: "orphan",
|
|
106
|
+
title: node.title,
|
|
107
|
+
state: node.state?.name ?? null,
|
|
108
|
+
},
|
|
109
|
+
receivedAt,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return signals;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=linear-issues.js.map
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CAAC,KAAK,EAAE,IAAI,IAAI,IAAI;iBAC/B;gBACD,UAAU;aACV,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { SignalSource as ConfigSignalSource } from "../config/types.js";
|
|
1
|
+
import type { SignalSource as ConfigSignalSource, LinearConfig } from "../config/types.js";
|
|
2
2
|
import type { SignalSourceImpl } from "./types.js";
|
|
3
|
-
export declare const IMPLEMENTED_SIGNAL_SOURCE_TYPES: readonly ["external_command"];
|
|
4
|
-
export declare
|
|
3
|
+
export declare const IMPLEMENTED_SIGNAL_SOURCE_TYPES: readonly ["external_command", "github_commits", "github_pr", "slack_messages", "linear_issues"];
|
|
4
|
+
export declare const EXTERNAL_COMMAND_ENV_FLAG = "LINEAR_ALLOW_EXTERNAL_COMMAND";
|
|
5
|
+
export declare function buildSignalSource(config: ConfigSignalSource, linearConfig: LinearConfig): SignalSourceImpl;
|
|
5
6
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/signals/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/signals/registry.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,IAAI,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAO3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,+BAA+B,iGAMlC,CAAC;AAIX,eAAO,MAAM,yBAAyB,kCAAkC,CAAC;AAOzE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,GAAG,gBAAgB,CA2B1G"}
|
package/dist/signals/registry.js
CHANGED
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
// Build a runtime SignalSource from a config entry.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
3
|
+
// Implementations are:
|
|
4
|
+
// external_command — generic shell extension point
|
|
5
|
+
// github_commits — git log on configured local repos
|
|
6
|
+
// github_pr — gh CLI against the configured GitHub repos
|
|
7
|
+
// slack_messages — Slack conversations.history via SLACK_TOKEN
|
|
8
|
+
// linear_issues — cross-issue scans (near-dup, x-ref, orphans)
|
|
9
|
+
//
|
|
10
|
+
// `mcp_tool` is declared in the schema but deferred to a future release.
|
|
9
11
|
import { ExternalCommandSource } from "./external-command.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
import { GithubCommitsSource } from "./github-commits.js";
|
|
13
|
+
import { GithubPrSource } from "./github-pr.js";
|
|
14
|
+
import { LinearIssuesSource } from "./linear-issues.js";
|
|
15
|
+
import { SlackMessagesSource } from "./slack-messages.js";
|
|
16
|
+
export const IMPLEMENTED_SIGNAL_SOURCE_TYPES = [
|
|
17
|
+
"external_command",
|
|
12
18
|
"github_commits",
|
|
13
19
|
"github_pr",
|
|
14
20
|
"slack_messages",
|
|
15
21
|
"linear_issues",
|
|
16
|
-
|
|
17
|
-
]);
|
|
18
|
-
export
|
|
22
|
+
];
|
|
23
|
+
const DECLARED_BUT_NOT_IMPLEMENTED = new Set(["mcp_tool"]);
|
|
24
|
+
export const EXTERNAL_COMMAND_ENV_FLAG = "LINEAR_ALLOW_EXTERNAL_COMMAND";
|
|
25
|
+
function externalCommandAllowed() {
|
|
26
|
+
const v = process.env[EXTERNAL_COMMAND_ENV_FLAG];
|
|
27
|
+
return v === "1" || v === "true";
|
|
28
|
+
}
|
|
29
|
+
export function buildSignalSource(config, linearConfig) {
|
|
19
30
|
switch (config.type) {
|
|
20
31
|
case "external_command":
|
|
32
|
+
if (!externalCommandAllowed()) {
|
|
33
|
+
throw new Error(`Signal source "${config.name}" is type "external_command" which executes arbitrary commands from references/signal-sources.json. Refusing to load: set ${EXTERNAL_COMMAND_ENV_FLAG}=1 to opt in. See SAFETY.md for details.`);
|
|
34
|
+
}
|
|
21
35
|
return new ExternalCommandSource(config);
|
|
36
|
+
case "github_commits":
|
|
37
|
+
return new GithubCommitsSource(config, linearConfig);
|
|
38
|
+
case "github_pr":
|
|
39
|
+
return new GithubPrSource(config, linearConfig);
|
|
40
|
+
case "slack_messages":
|
|
41
|
+
return new SlackMessagesSource(config, linearConfig);
|
|
42
|
+
case "linear_issues":
|
|
43
|
+
return new LinearIssuesSource(config);
|
|
22
44
|
default:
|
|
23
45
|
if (DECLARED_BUT_NOT_IMPLEMENTED.has(config.type)) {
|
|
24
46
|
throw new Error(`Signal source type "${config.type}" is declared in the schema but not yet implemented in this version. Currently supported: ${IMPLEMENTED_SIGNAL_SOURCE_TYPES.join(", ")}.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/signals/registry.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/signals/registry.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,uBAAuB;AACvB,uDAAuD;AACvD,2DAA2D;AAC3D,oEAAoE;AACpE,qEAAqE;AACrE,sEAAsE;AACtE,EAAE;AACF,yEAAyE;AAIzE,OAAO,EAA8B,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAA4B,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAuB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAA4B,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGpF,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,kBAAkB;IAClB,gBAAgB;IAChB,WAAW;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I,iBAAiB,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACxG,CAAC;IACJ,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LinearConfig } from "../config/types.js";
|
|
2
|
+
import type { Signal, SignalSourceContext, SignalSourceImpl } from "./types.js";
|
|
3
|
+
export interface SlackMessagesConfig {
|
|
4
|
+
type: "slack_messages";
|
|
5
|
+
name: string;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
channels?: string[];
|
|
8
|
+
match_patterns?: string[];
|
|
9
|
+
lookback_hours?: number;
|
|
10
|
+
}
|
|
11
|
+
type FetchLike = typeof fetch;
|
|
12
|
+
export declare function setSlackFetchForTesting(impl: FetchLike | null): void;
|
|
13
|
+
export declare class SlackMessagesSource implements SignalSourceImpl {
|
|
14
|
+
readonly config: SlackMessagesConfig;
|
|
15
|
+
private readonly linearConfig;
|
|
16
|
+
constructor(config: SlackMessagesConfig, linearConfig: LinearConfig);
|
|
17
|
+
collect(ctx: SignalSourceContext): Promise<Signal[]>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=slack-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-messages.d.ts","sourceRoot":"","sources":["../../src/signals/slack-messages.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAOhF,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAeD,KAAK,SAAS,GAAG,OAAO,KAAK,CAAC;AAE9B,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAEpE;AAOD,qBAAa,mBAAoB,YAAW,gBAAgB;IAC3D,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;gBAEhC,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,YAAY;IAK7D,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAqG1D"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// `slack_messages` signal source.
|
|
2
|
+
//
|
|
3
|
+
// Polls Slack `conversations.history` for the configured channel IDs and
|
|
4
|
+
// filters messages by `match_patterns` — each pattern is compiled to a
|
|
5
|
+
// case-insensitive, word-boundary regex (so "prod" doesn't match "reproduce").
|
|
6
|
+
// Regex metacharacters in the user-supplied pattern are escaped. Issue
|
|
7
|
+
// identifiers in matched messages are extracted via the team-prefix regex
|
|
8
|
+
// derived from references/teams.json.
|
|
9
|
+
//
|
|
10
|
+
// Auth: requires SLACK_TOKEN (Bot or User token) in the environment. Without
|
|
11
|
+
// it the source emits one warning signal and returns.
|
|
12
|
+
import { _internal as commitsInternal } from "./github-commits.js";
|
|
13
|
+
const SLACK_API = "https://slack.com/api";
|
|
14
|
+
const DEFAULT_LOOKBACK_HOURS = 24;
|
|
15
|
+
const HISTORY_LIMIT = 200;
|
|
16
|
+
const TIMEOUT_MS = 30_000;
|
|
17
|
+
let fetchImpl = fetch;
|
|
18
|
+
export function setSlackFetchForTesting(impl) {
|
|
19
|
+
fetchImpl = impl ?? fetch;
|
|
20
|
+
}
|
|
21
|
+
function toWordBoundaryRegex(pattern) {
|
|
22
|
+
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
23
|
+
return new RegExp(`\\b${escaped}\\b`, "i");
|
|
24
|
+
}
|
|
25
|
+
export class SlackMessagesSource {
|
|
26
|
+
config;
|
|
27
|
+
linearConfig;
|
|
28
|
+
constructor(config, linearConfig) {
|
|
29
|
+
this.config = config;
|
|
30
|
+
this.linearConfig = linearConfig;
|
|
31
|
+
}
|
|
32
|
+
async collect(ctx) {
|
|
33
|
+
const receivedAt = ctx.now.toISOString();
|
|
34
|
+
const token = process.env.SLACK_TOKEN;
|
|
35
|
+
if (!token) {
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
source: this.config.name,
|
|
39
|
+
type: this.config.type,
|
|
40
|
+
payload: { warning: "SLACK_TOKEN not set; skipped" },
|
|
41
|
+
receivedAt,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
const teamKeys = this.linearConfig.teams.teams.map((t) => t.key);
|
|
46
|
+
const issueRegex = commitsInternal.buildTeamRegex(teamKeys);
|
|
47
|
+
// Compile each match pattern as a case-insensitive, word-boundary regex
|
|
48
|
+
// so e.g. "prod" doesn't fire on "reproduce" or "qa" on "equal". Anything
|
|
49
|
+
// that doesn't compile (user-supplied regex metachars) is treated as a
|
|
50
|
+
// plain word and escaped.
|
|
51
|
+
const patterns = (this.config.match_patterns ?? []).map(toWordBoundaryRegex);
|
|
52
|
+
const lookback = (this.config.lookback_hours ?? DEFAULT_LOOKBACK_HOURS) * 3600;
|
|
53
|
+
const oldest = (ctx.now.getTime() / 1000 - lookback).toFixed(3);
|
|
54
|
+
const channels = this.config.channels && this.config.channels.length > 0
|
|
55
|
+
? this.config.channels
|
|
56
|
+
: this.linearConfig.slack.allowed_channels;
|
|
57
|
+
const signals = [];
|
|
58
|
+
for (const channel of channels) {
|
|
59
|
+
let payload;
|
|
60
|
+
try {
|
|
61
|
+
const url = new URL(`${SLACK_API}/conversations.history`);
|
|
62
|
+
url.searchParams.set("channel", channel);
|
|
63
|
+
url.searchParams.set("limit", String(HISTORY_LIMIT));
|
|
64
|
+
url.searchParams.set("oldest", oldest);
|
|
65
|
+
const controller = new AbortController();
|
|
66
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
67
|
+
let res;
|
|
68
|
+
try {
|
|
69
|
+
res = await fetchImpl(url, {
|
|
70
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
71
|
+
signal: controller.signal,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
}
|
|
77
|
+
payload = (await res.json());
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
signals.push({
|
|
81
|
+
source: this.config.name,
|
|
82
|
+
type: this.config.type,
|
|
83
|
+
payload: { warning: `slack history failed for "${channel}": ${err.message}` },
|
|
84
|
+
receivedAt,
|
|
85
|
+
});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!payload.ok) {
|
|
89
|
+
signals.push({
|
|
90
|
+
source: this.config.name,
|
|
91
|
+
type: this.config.type,
|
|
92
|
+
payload: { warning: `slack returned error for "${channel}": ${payload.error ?? "unknown"}` },
|
|
93
|
+
receivedAt,
|
|
94
|
+
});
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
for (const msg of payload.messages ?? []) {
|
|
98
|
+
if (!msg.text)
|
|
99
|
+
continue;
|
|
100
|
+
if (msg.subtype === "bot_message" || msg.subtype === "channel_join")
|
|
101
|
+
continue;
|
|
102
|
+
if (patterns.length > 0 && !patterns.some((re) => re.test(msg.text)))
|
|
103
|
+
continue;
|
|
104
|
+
const ids = commitsInternal.extractIssueIds(msg.text, issueRegex);
|
|
105
|
+
const base = {
|
|
106
|
+
channel,
|
|
107
|
+
ts: msg.ts,
|
|
108
|
+
user: msg.user ?? null,
|
|
109
|
+
text: msg.text,
|
|
110
|
+
};
|
|
111
|
+
if (ids.length === 0) {
|
|
112
|
+
signals.push({ source: this.config.name, type: this.config.type, payload: base, receivedAt });
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
for (const id of ids) {
|
|
116
|
+
signals.push({
|
|
117
|
+
source: this.config.name,
|
|
118
|
+
type: this.config.type,
|
|
119
|
+
issueIdentifier: id,
|
|
120
|
+
payload: base,
|
|
121
|
+
receivedAt,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return signals;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=slack-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-messages.js","sourceRoot":"","sources":["../../src/signals/slack-messages.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,+EAA+E;AAC/E,uEAAuE;AACvE,0EAA0E;AAC1E,sCAAsC;AACtC,EAAE;AACF,6EAA6E;AAC7E,sDAAsD;AAGtD,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGnE,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAC1C,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,UAAU,GAAG,MAAM,CAAC;AAyB1B,IAAI,SAAS,GAAc,KAAK,CAAC;AACjC,MAAM,UAAU,uBAAuB,CAAC,IAAsB;IAC7D,SAAS,GAAG,IAAI,IAAI,KAAK,CAAC;AAC3B,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAe;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAC/D,OAAO,IAAI,MAAM,CAAC,MAAM,OAAO,KAAK,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAsB;IACpB,YAAY,CAAe;IAE5C,YAAY,MAA2B,EAAE,YAA0B;QAClE,IAAI,CAAC,MA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