gitmem-mcp 1.0.1 → 1.0.3
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/CHANGELOG.md +21 -0
- package/README.md +90 -184
- package/dist/index.js +0 -0
- package/dist/schemas/create-learning.d.ts +4 -4
- package/dist/services/agent-briefing.d.ts +12 -0
- package/dist/services/agent-briefing.d.ts.map +1 -0
- package/dist/services/agent-briefing.js +81 -0
- package/dist/services/agent-briefing.js.map +1 -0
- package/dist/services/agent-detection.d.ts +1 -1
- package/dist/services/agent-detection.js +3 -3
- package/dist/services/agent-detection.js.map +1 -1
- package/dist/services/local-file-storage.d.ts.map +1 -1
- package/dist/services/local-file-storage.js +13 -8
- package/dist/services/local-file-storage.js.map +1 -1
- package/dist/services/tier.d.ts +2 -0
- package/dist/services/tier.d.ts.map +1 -1
- package/dist/services/tier.js +4 -0
- package/dist/services/tier.js.map +1 -1
- package/dist/services/triple-writer.d.ts +4 -4
- package/dist/services/triple-writer.d.ts.map +1 -1
- package/dist/services/triple-writer.js +11 -20
- package/dist/services/triple-writer.js.map +1 -1
- package/dist/tools/confirm-scars.d.ts.map +1 -1
- package/dist/tools/confirm-scars.js +4 -0
- package/dist/tools/confirm-scars.js.map +1 -1
- package/dist/tools/definitions.d.ts +280 -58
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/definitions.js +80 -42
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/graph-traverse.d.ts +1 -1
- package/dist/tools/graph-traverse.d.ts.map +1 -1
- package/dist/tools/graph-traverse.js +3 -2
- package/dist/tools/graph-traverse.js.map +1 -1
- package/dist/tools/prepare-context.js +1 -1
- package/dist/tools/recall.d.ts +1 -0
- package/dist/tools/recall.d.ts.map +1 -1
- package/dist/tools/recall.js +15 -6
- package/dist/tools/recall.js.map +1 -1
- package/dist/tools/session-close.d.ts.map +1 -1
- package/dist/tools/session-close.js +35 -34
- package/dist/tools/session-close.js.map +1 -1
- package/dist/tools/session-start.d.ts.map +1 -1
- package/dist/tools/session-start.js +2 -0
- package/dist/tools/session-start.js.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/schema/starter-scars.json +3 -153
- package/dist/tools/create-linear-issue.d.ts +0 -18
- package/dist/tools/create-linear-issue.d.ts.map +0 -1
- package/dist/tools/create-linear-issue.js +0 -197
- package/dist/tools/create-linear-issue.js.map +0 -1
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
[
|
|
2
|
-
{
|
|
3
|
-
"id": "00000000-0000-0000-0000-000000000001",
|
|
4
|
-
"learning_type": "scar",
|
|
5
|
-
"title": "Tests Pass Locally But Fail in CI",
|
|
6
|
-
"description": "Local test environments often differ from CI (different OS, Node version, env vars, timing). Code that passes locally may fail in CI due to missing environment variables, hardcoded paths, race conditions, or dependency version differences. Always verify in CI before declaring 'it works'.",
|
|
7
|
-
"severity": "high",
|
|
8
|
-
"scar_type": "verification",
|
|
9
|
-
"counter_arguments": [
|
|
10
|
-
"Our CI config matches local exactly — but environment variables, caching, and timing can still differ",
|
|
11
|
-
"We have good test coverage so local passing is enough — but coverage doesn't catch environment-specific issues"
|
|
12
|
-
],
|
|
13
|
-
"keywords": ["tests", "ci", "local", "environment", "flaky"],
|
|
14
|
-
"domain": ["testing", "ci-cd"],
|
|
15
|
-
"project": "default",
|
|
16
|
-
"source_date": "2026-01-01",
|
|
17
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
18
|
-
},
|
|
19
2
|
{
|
|
20
3
|
"id": "00000000-0000-0000-0000-000000000002",
|
|
21
4
|
"learning_type": "scar",
|
|
@@ -23,6 +6,7 @@
|
|
|
23
6
|
"description": "Code being 'done' (merged) doesn't mean it's deployed, and being deployed doesn't mean it's working correctly in production. The full loop is: merge → deploy → verify the feature works end-to-end in the target environment. Skipping verification leads to silent failures.",
|
|
24
7
|
"severity": "critical",
|
|
25
8
|
"scar_type": "verification",
|
|
9
|
+
"is_starter": true,
|
|
26
10
|
"counter_arguments": [
|
|
27
11
|
"Our deployment pipeline is automated so merge = deploy — but automated doesn't mean verified working",
|
|
28
12
|
"We have monitoring that would catch issues — but monitoring has blind spots and alert fatigue is real"
|
|
@@ -33,23 +17,6 @@
|
|
|
33
17
|
"source_date": "2026-01-01",
|
|
34
18
|
"created_at": "2026-01-01T00:00:00Z"
|
|
35
19
|
},
|
|
36
|
-
{
|
|
37
|
-
"id": "00000000-0000-0000-0000-000000000003",
|
|
38
|
-
"learning_type": "scar",
|
|
39
|
-
"title": "Environment Variables Missing in Production",
|
|
40
|
-
"description": "New features that rely on environment variables frequently fail in production because the variables were set locally but never added to the production environment. Always document required env vars and verify they exist in all target environments before deploying.",
|
|
41
|
-
"severity": "high",
|
|
42
|
-
"scar_type": "deployment",
|
|
43
|
-
"counter_arguments": [
|
|
44
|
-
"We have a .env.example that tracks all variables — but .env.example and actual production config drift apart",
|
|
45
|
-
"Our deployment checklist covers env vars — but checklists get skipped under time pressure"
|
|
46
|
-
],
|
|
47
|
-
"keywords": ["environment", "variables", "production", "config", "missing"],
|
|
48
|
-
"domain": ["deployment", "configuration"],
|
|
49
|
-
"project": "default",
|
|
50
|
-
"source_date": "2026-01-01",
|
|
51
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
52
|
-
},
|
|
53
20
|
{
|
|
54
21
|
"id": "00000000-0000-0000-0000-000000000004",
|
|
55
22
|
"learning_type": "scar",
|
|
@@ -57,6 +24,7 @@
|
|
|
57
24
|
"description": "Running database migrations without a tested rollback plan risks data loss or extended downtime. Destructive migrations (dropping columns, changing types) are especially dangerous. Always write and test the down migration before running the up migration in production.",
|
|
58
25
|
"severity": "critical",
|
|
59
26
|
"scar_type": "architectural",
|
|
27
|
+
"is_starter": true,
|
|
60
28
|
"counter_arguments": [
|
|
61
29
|
"This migration is additive so it's safe — but even additive migrations can fail and leave the schema in a partial state",
|
|
62
30
|
"We can always restore from backup — but backup restoration takes time and may lose recent data"
|
|
@@ -67,91 +35,6 @@
|
|
|
67
35
|
"source_date": "2026-01-01",
|
|
68
36
|
"created_at": "2026-01-01T00:00:00Z"
|
|
69
37
|
},
|
|
70
|
-
{
|
|
71
|
-
"id": "00000000-0000-0000-0000-000000000005",
|
|
72
|
-
"learning_type": "scar",
|
|
73
|
-
"title": "Hardcoded Secrets in Source Code",
|
|
74
|
-
"description": "API keys, database passwords, and other secrets hardcoded in source code inevitably leak — through git history, logs, error messages, or public repos. Always use environment variables or a secrets manager. If a secret was ever committed, rotate it immediately.",
|
|
75
|
-
"severity": "critical",
|
|
76
|
-
"scar_type": "security",
|
|
77
|
-
"counter_arguments": [
|
|
78
|
-
"This is a private repo so it's fine — but private repos get forked, team members change, and git history is forever",
|
|
79
|
-
"It's just a dev/test key — but dev keys often have more permissions than expected and habits carry to production"
|
|
80
|
-
],
|
|
81
|
-
"keywords": ["secrets", "api-keys", "security", "hardcoded", "credentials"],
|
|
82
|
-
"domain": ["security", "configuration"],
|
|
83
|
-
"project": "default",
|
|
84
|
-
"source_date": "2026-01-01",
|
|
85
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"id": "00000000-0000-0000-0000-000000000006",
|
|
89
|
-
"learning_type": "scar",
|
|
90
|
-
"title": "API Breaking Change Without Versioning",
|
|
91
|
-
"description": "Changing API response shapes, removing fields, or modifying behavior without versioning breaks downstream consumers silently. Even 'internal' APIs often have more consumers than expected. Use API versioning and deprecation periods for any breaking change.",
|
|
92
|
-
"severity": "high",
|
|
93
|
-
"scar_type": "architectural",
|
|
94
|
-
"counter_arguments": [
|
|
95
|
-
"Only our own frontend uses this API — but other teams, scripts, and integrations may depend on it too",
|
|
96
|
-
"We can coordinate the change with all consumers — but coordinated deploys are fragile and someone always gets missed"
|
|
97
|
-
],
|
|
98
|
-
"keywords": ["api", "breaking-change", "versioning", "backwards-compatibility"],
|
|
99
|
-
"domain": ["api", "architecture"],
|
|
100
|
-
"project": "default",
|
|
101
|
-
"source_date": "2026-01-01",
|
|
102
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"id": "00000000-0000-0000-0000-000000000007",
|
|
106
|
-
"learning_type": "scar",
|
|
107
|
-
"title": "Cache Invalidation After Data Update",
|
|
108
|
-
"description": "When data is updated but cached values aren't invalidated, users see stale data. This is especially insidious because it works 'sometimes' (when the cache expires naturally). Always identify all caches that need invalidation when changing underlying data.",
|
|
109
|
-
"severity": "medium",
|
|
110
|
-
"scar_type": "operational",
|
|
111
|
-
"counter_arguments": [
|
|
112
|
-
"Our cache TTL is short enough that staleness is acceptable — but even short TTLs cause confusion during testing and demos",
|
|
113
|
-
"We don't use caching in this part of the system — but CDNs, browser caches, and ORM-level caches are often invisible"
|
|
114
|
-
],
|
|
115
|
-
"keywords": ["cache", "invalidation", "stale-data", "ttl"],
|
|
116
|
-
"domain": ["caching", "data"],
|
|
117
|
-
"project": "default",
|
|
118
|
-
"source_date": "2026-01-01",
|
|
119
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
"id": "00000000-0000-0000-0000-000000000008",
|
|
123
|
-
"learning_type": "scar",
|
|
124
|
-
"title": "Off-by-One Errors in Pagination",
|
|
125
|
-
"description": "Pagination logic is a common source of off-by-one errors: skipping the first item, duplicating items at page boundaries, or returning empty last pages. Always test pagination with 0 items, 1 item, exactly page-size items, and page-size + 1 items.",
|
|
126
|
-
"severity": "medium",
|
|
127
|
-
"scar_type": "verification",
|
|
128
|
-
"counter_arguments": [
|
|
129
|
-
"Our pagination uses a well-tested library — but the integration between your offset/cursor logic and the library is where bugs hide",
|
|
130
|
-
"We tested with a few pages and it works — but edge cases at boundaries and with concurrent modifications are where pagination breaks"
|
|
131
|
-
],
|
|
132
|
-
"keywords": ["pagination", "off-by-one", "cursor", "offset", "boundary"],
|
|
133
|
-
"domain": ["api", "data"],
|
|
134
|
-
"project": "default",
|
|
135
|
-
"source_date": "2026-01-01",
|
|
136
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"id": "00000000-0000-0000-0000-000000000009",
|
|
140
|
-
"learning_type": "scar",
|
|
141
|
-
"title": "Timezone Bugs Between Server and Client",
|
|
142
|
-
"description": "Timezone handling between server (usually UTC) and client (user's local timezone) is a frequent source of bugs. Dates that 'look right' in development (same timezone) break for users in different timezones. Always store dates as UTC and convert only at the display layer.",
|
|
143
|
-
"severity": "medium",
|
|
144
|
-
"scar_type": "operational",
|
|
145
|
-
"counter_arguments": [
|
|
146
|
-
"We already use UTC everywhere — but date libraries and database functions sometimes apply local timezone implicitly",
|
|
147
|
-
"Our users are all in one timezone — but that assumption breaks when the product grows or developers travel"
|
|
148
|
-
],
|
|
149
|
-
"keywords": ["timezone", "utc", "date", "time", "client-server"],
|
|
150
|
-
"domain": ["frontend", "backend", "data"],
|
|
151
|
-
"project": "default",
|
|
152
|
-
"source_date": "2026-01-01",
|
|
153
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
154
|
-
},
|
|
155
38
|
{
|
|
156
39
|
"id": "00000000-0000-0000-0000-000000000010",
|
|
157
40
|
"learning_type": "scar",
|
|
@@ -159,6 +42,7 @@
|
|
|
159
42
|
"description": "Empty catch blocks and generic error handlers that log but don't surface errors lead to silent failures. The system appears to work while data is lost or corrupted. At minimum, log errors with enough context to diagnose the issue. Better: fail visibly so problems are caught early.",
|
|
160
43
|
"severity": "high",
|
|
161
44
|
"scar_type": "operational",
|
|
45
|
+
"is_starter": true,
|
|
162
46
|
"counter_arguments": [
|
|
163
47
|
"We catch errors to prevent crashes — but catching without handling is worse than crashing because the problem is hidden",
|
|
164
48
|
"The error is non-critical so swallowing it is fine — but 'non-critical' errors compound and mask the root cause of critical issues"
|
|
@@ -168,39 +52,5 @@
|
|
|
168
52
|
"project": "default",
|
|
169
53
|
"source_date": "2026-01-01",
|
|
170
54
|
"created_at": "2026-01-01T00:00:00Z"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"id": "00000000-0000-0000-0000-000000000011",
|
|
174
|
-
"learning_type": "scar",
|
|
175
|
-
"title": "Long-Lived Feature Branches Create Merge Hell",
|
|
176
|
-
"description": "Feature branches that diverge from main for more than a few days accumulate merge conflicts and integration issues. The longer a branch lives, the harder and riskier the merge. Break large features into small, mergeable increments behind feature flags if needed.",
|
|
177
|
-
"severity": "medium",
|
|
178
|
-
"scar_type": "process",
|
|
179
|
-
"counter_arguments": [
|
|
180
|
-
"This feature is too big to merge incrementally — but that means the feature should be broken into smaller deliverables",
|
|
181
|
-
"We'll merge when it's fully done to avoid shipping incomplete features — but feature flags solve this without the merge risk"
|
|
182
|
-
],
|
|
183
|
-
"keywords": ["git", "branch", "merge", "conflict", "feature-flag"],
|
|
184
|
-
"domain": ["git", "process"],
|
|
185
|
-
"project": "default",
|
|
186
|
-
"source_date": "2026-01-01",
|
|
187
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
"id": "00000000-0000-0000-0000-000000000012",
|
|
191
|
-
"learning_type": "scar",
|
|
192
|
-
"title": "Premature Abstraction Increases Complexity",
|
|
193
|
-
"description": "Creating abstractions, helpers, and shared utilities before you have at least 3 concrete use cases leads to wrong abstractions that are harder to change than duplicated code. Wait until patterns emerge naturally. Three similar implementations reveal the right abstraction; one guess rarely does.",
|
|
194
|
-
"severity": "medium",
|
|
195
|
-
"scar_type": "architectural",
|
|
196
|
-
"counter_arguments": [
|
|
197
|
-
"DRY principle says we should never duplicate code — but WET (Write Everything Twice) is better than wrong abstractions",
|
|
198
|
-
"Good architecture means planning ahead — but over-engineering for hypothetical futures wastes time and adds complexity"
|
|
199
|
-
],
|
|
200
|
-
"keywords": ["abstraction", "dry", "complexity", "over-engineering", "refactoring"],
|
|
201
|
-
"domain": ["architecture", "design"],
|
|
202
|
-
"project": "default",
|
|
203
|
-
"source_date": "2026-01-01",
|
|
204
|
-
"created_at": "2026-01-01T00:00:00Z"
|
|
205
55
|
}
|
|
206
56
|
]
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* create_linear_issue Tool (OD-611)
|
|
3
|
-
*
|
|
4
|
-
* Proxy Linear issue creation via GraphQL API.
|
|
5
|
-
* Returns slim response (~50 tokens) instead of Linear MCP's ~1400 tokens.
|
|
6
|
-
*
|
|
7
|
-
* Pattern: File-based payload handoff (same as session_close).
|
|
8
|
-
* Agent writes description to .gitmem/issue-payload.json, then calls this
|
|
9
|
-
* tool with title + teamId inline. Tool reads, merges, calls Linear, deletes file.
|
|
10
|
-
*
|
|
11
|
-
* Performance target: <2000ms (one network call)
|
|
12
|
-
*/
|
|
13
|
-
import type { CreateLinearIssueParams, CreateLinearIssueResult } from "../types/index.js";
|
|
14
|
-
/**
|
|
15
|
-
* Create a Linear issue via GraphQL API with slim response.
|
|
16
|
-
*/
|
|
17
|
-
export declare function createLinearIssue(params: CreateLinearIssueParams): Promise<CreateLinearIssueResult>;
|
|
18
|
-
//# sourceMappingURL=create-linear-issue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-linear-issue.d.ts","sourceRoot":"","sources":["../../src/tools/create-linear-issue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAqB3B;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC,CAgOlC"}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* create_linear_issue Tool (OD-611)
|
|
3
|
-
*
|
|
4
|
-
* Proxy Linear issue creation via GraphQL API.
|
|
5
|
-
* Returns slim response (~50 tokens) instead of Linear MCP's ~1400 tokens.
|
|
6
|
-
*
|
|
7
|
-
* Pattern: File-based payload handoff (same as session_close).
|
|
8
|
-
* Agent writes description to .gitmem/issue-payload.json, then calls this
|
|
9
|
-
* tool with title + teamId inline. Tool reads, merges, calls Linear, deletes file.
|
|
10
|
-
*
|
|
11
|
-
* Performance target: <2000ms (one network call)
|
|
12
|
-
*/
|
|
13
|
-
import * as fs from "fs";
|
|
14
|
-
import { v4 as uuidv4 } from "uuid";
|
|
15
|
-
import { getGitmemPath } from "../services/gitmem-dir.js";
|
|
16
|
-
import { Timer, buildPerformanceData, recordMetrics, } from "../services/metrics.js";
|
|
17
|
-
import { getEffectTracker } from "../services/effect-tracker.js";
|
|
18
|
-
const LINEAR_API_URL = "https://api.linear.app/graphql";
|
|
19
|
-
/** GraphQL mutation — request only the fields needed for the slim response */
|
|
20
|
-
const ISSUE_CREATE_MUTATION = `
|
|
21
|
-
mutation IssueCreate($input: IssueCreateInput!) {
|
|
22
|
-
issueCreate(input: $input) {
|
|
23
|
-
success
|
|
24
|
-
issue {
|
|
25
|
-
id
|
|
26
|
-
identifier
|
|
27
|
-
url
|
|
28
|
-
state {
|
|
29
|
-
name
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
`;
|
|
35
|
-
/**
|
|
36
|
-
* Create a Linear issue via GraphQL API with slim response.
|
|
37
|
-
*/
|
|
38
|
-
export async function createLinearIssue(params) {
|
|
39
|
-
const timer = new Timer();
|
|
40
|
-
const metricsId = uuidv4();
|
|
41
|
-
// 1. Check LINEAR_API_KEY
|
|
42
|
-
const apiKey = process.env.LINEAR_API_KEY;
|
|
43
|
-
if (!apiKey) {
|
|
44
|
-
const latencyMs = timer.stop();
|
|
45
|
-
return {
|
|
46
|
-
success: false,
|
|
47
|
-
error: "LINEAR_API_KEY environment variable is not set. Add it to your MCP server configuration.",
|
|
48
|
-
performance: buildPerformanceData("create_linear_issue", latencyMs, 0),
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// 2. Load file-based payload (same pattern as session_close)
|
|
52
|
-
const payloadPath = params.payload_path || getGitmemPath("issue-payload.json");
|
|
53
|
-
let filePayload = {};
|
|
54
|
-
try {
|
|
55
|
-
if (fs.existsSync(payloadPath)) {
|
|
56
|
-
filePayload = JSON.parse(fs.readFileSync(payloadPath, "utf-8"));
|
|
57
|
-
console.error(`[create_linear_issue] Loaded payload from ${payloadPath}`);
|
|
58
|
-
// Clean up payload file after reading
|
|
59
|
-
try {
|
|
60
|
-
fs.unlinkSync(payloadPath);
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
/* ignore cleanup errors */
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
console.error("[create_linear_issue] Failed to read issue-payload.json:", error);
|
|
69
|
-
}
|
|
70
|
-
// 3. Merge: inline params override file payload
|
|
71
|
-
const teamId = params.teamId || filePayload.teamId;
|
|
72
|
-
const title = params.title || filePayload.title;
|
|
73
|
-
if (!teamId || !title) {
|
|
74
|
-
const latencyMs = timer.stop();
|
|
75
|
-
return {
|
|
76
|
-
success: false,
|
|
77
|
-
error: "teamId and title are required. Provide inline or in .gitmem/issue-payload.json.",
|
|
78
|
-
performance: buildPerformanceData("create_linear_issue", latencyMs, 0),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
// 4. Build IssueCreateInput for GraphQL
|
|
82
|
-
const input = {
|
|
83
|
-
teamId,
|
|
84
|
-
title,
|
|
85
|
-
};
|
|
86
|
-
// Description only comes from file payload (the large field)
|
|
87
|
-
if (filePayload.description) {
|
|
88
|
-
input.description = filePayload.description;
|
|
89
|
-
}
|
|
90
|
-
// Merge optional fields — inline overrides file
|
|
91
|
-
if (params.priority !== undefined || filePayload.priority !== undefined) {
|
|
92
|
-
input.priority = params.priority ?? filePayload.priority;
|
|
93
|
-
}
|
|
94
|
-
if (params.labelIds?.length || filePayload.labelIds?.length) {
|
|
95
|
-
input.labelIds = params.labelIds || filePayload.labelIds;
|
|
96
|
-
}
|
|
97
|
-
if (params.projectId || filePayload.projectId) {
|
|
98
|
-
input.projectId = params.projectId || filePayload.projectId;
|
|
99
|
-
}
|
|
100
|
-
if (params.assigneeId || filePayload.assigneeId) {
|
|
101
|
-
input.assigneeId = params.assigneeId || filePayload.assigneeId;
|
|
102
|
-
}
|
|
103
|
-
if (params.parentId || filePayload.parentId) {
|
|
104
|
-
input.parentId = params.parentId || filePayload.parentId;
|
|
105
|
-
}
|
|
106
|
-
if (params.stateId || filePayload.stateId) {
|
|
107
|
-
input.stateId = params.stateId || filePayload.stateId;
|
|
108
|
-
}
|
|
109
|
-
if (params.estimate !== undefined || filePayload.estimate !== undefined) {
|
|
110
|
-
input.estimate = params.estimate ?? filePayload.estimate;
|
|
111
|
-
}
|
|
112
|
-
// 5. Call Linear GraphQL API
|
|
113
|
-
try {
|
|
114
|
-
const response = await fetch(LINEAR_API_URL, {
|
|
115
|
-
method: "POST",
|
|
116
|
-
headers: {
|
|
117
|
-
"Content-Type": "application/json",
|
|
118
|
-
Authorization: apiKey,
|
|
119
|
-
},
|
|
120
|
-
body: JSON.stringify({
|
|
121
|
-
query: ISSUE_CREATE_MUTATION,
|
|
122
|
-
variables: { input },
|
|
123
|
-
}),
|
|
124
|
-
});
|
|
125
|
-
if (!response.ok) {
|
|
126
|
-
const text = await response.text();
|
|
127
|
-
const latencyMs = timer.stop();
|
|
128
|
-
return {
|
|
129
|
-
success: false,
|
|
130
|
-
error: `Linear API HTTP ${response.status}: ${text.slice(0, 200)}`,
|
|
131
|
-
performance: buildPerformanceData("create_linear_issue", latencyMs, 0),
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const data = (await response.json());
|
|
135
|
-
// Handle GraphQL errors
|
|
136
|
-
if (data.errors?.length) {
|
|
137
|
-
const latencyMs = timer.stop();
|
|
138
|
-
return {
|
|
139
|
-
success: false,
|
|
140
|
-
error: `Linear GraphQL error: ${data.errors.map((e) => e.message).join("; ")}`,
|
|
141
|
-
performance: buildPerformanceData("create_linear_issue", latencyMs, 0),
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
const issueCreate = data.data?.issueCreate;
|
|
145
|
-
if (!issueCreate?.success || !issueCreate.issue) {
|
|
146
|
-
const latencyMs = timer.stop();
|
|
147
|
-
return {
|
|
148
|
-
success: false,
|
|
149
|
-
error: "Linear API returned unsuccessful issueCreate",
|
|
150
|
-
performance: buildPerformanceData("create_linear_issue", latencyMs, 0),
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
const issue = issueCreate.issue;
|
|
154
|
-
const latencyMs = timer.stop();
|
|
155
|
-
// 6. Fire-and-forget metrics recording
|
|
156
|
-
getEffectTracker().track("metrics", "create_linear_issue", () => recordMetrics({
|
|
157
|
-
id: metricsId,
|
|
158
|
-
tool_name: "create_linear_issue",
|
|
159
|
-
latency_ms: latencyMs,
|
|
160
|
-
result_count: 1,
|
|
161
|
-
metadata: {
|
|
162
|
-
identifier: issue.identifier,
|
|
163
|
-
teamId,
|
|
164
|
-
has_description: !!filePayload.description,
|
|
165
|
-
},
|
|
166
|
-
}));
|
|
167
|
-
// 7. Return slim response (~50 tokens vs ~1400)
|
|
168
|
-
return {
|
|
169
|
-
success: true,
|
|
170
|
-
identifier: issue.identifier,
|
|
171
|
-
url: issue.url,
|
|
172
|
-
id: issue.id,
|
|
173
|
-
state: issue.state?.name,
|
|
174
|
-
performance: buildPerformanceData("create_linear_issue", latencyMs, 1, {
|
|
175
|
-
breakdown: {
|
|
176
|
-
upsert: {
|
|
177
|
-
latency_ms: latencyMs,
|
|
178
|
-
source: "supabase",
|
|
179
|
-
cache_status: "not_applicable",
|
|
180
|
-
network_call: true,
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
}),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
catch (error) {
|
|
187
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
188
|
-
console.error("[create_linear_issue] Failed:", error);
|
|
189
|
-
const latencyMs = timer.stop();
|
|
190
|
-
return {
|
|
191
|
-
success: false,
|
|
192
|
-
error: `Linear API call failed: ${errorMessage}`,
|
|
193
|
-
performance: buildPerformanceData("create_linear_issue", latencyMs, 0),
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=create-linear-issue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-linear-issue.js","sourceRoot":"","sources":["../../src/tools/create-linear-issue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,KAAK,EACL,oBAAoB,EACpB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAMjE,MAAM,cAAc,GAAG,gCAAgC,CAAC;AAExD,8EAA8E;AAC9E,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;CAc7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA+B;IAE/B,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;IAC1B,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;IAE3B,0BAA0B;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC/B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EACH,0FAA0F;YAC5F,WAAW,EAAE,oBAAoB,CAC/B,qBAAqB,EACrB,SAAS,EACT,CAAC,CACF;SACF,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC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