git-impact 0.3.0 → 0.6.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 +124 -78
- package/dist/cli/index.js +32 -211
- package/dist/cli/index.js.map +1 -1
- package/dist/init/installer.d.ts +6 -0
- package/dist/init/installer.d.ts.map +1 -1
- package/dist/init/installer.js +58 -5
- package/dist/init/installer.js.map +1 -1
- package/dist/init/installer.test.d.ts +2 -0
- package/dist/init/installer.test.d.ts.map +1 -0
- package/dist/init/installer.test.js +127 -0
- package/dist/init/installer.test.js.map +1 -0
- package/dist/init/templates.d.ts +8 -7
- package/dist/init/templates.d.ts.map +1 -1
- package/dist/init/templates.js +73 -371
- package/dist/init/templates.js.map +1 -1
- package/dist/mcp/resources.js +0 -1
- package/dist/mcp/resources.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +64 -12
- package/dist/mcp/tools.js.map +1 -1
- package/dist/readers/git.d.ts +2 -1
- package/dist/readers/git.d.ts.map +1 -1
- package/dist/readers/git.js +12 -6
- package/dist/readers/git.js.map +1 -1
- package/dist/readers/redact.d.ts +29 -0
- package/dist/readers/redact.d.ts.map +1 -0
- package/dist/readers/redact.js +82 -0
- package/dist/readers/redact.js.map +1 -0
- package/dist/readers/redact.test.d.ts +2 -0
- package/dist/readers/redact.test.d.ts.map +1 -0
- package/dist/readers/redact.test.js +72 -0
- package/dist/readers/redact.test.js.map +1 -0
- package/dist/report/html.d.ts +2 -0
- package/dist/report/html.d.ts.map +1 -1
- package/dist/report/html.js +35 -1
- package/dist/report/html.js.map +1 -1
- package/dist/report/render.d.ts.map +1 -1
- package/dist/report/render.js +2 -0
- package/dist/report/render.js.map +1 -1
- package/dist/storage/db.d.ts +23 -2
- package/dist/storage/db.d.ts.map +1 -1
- package/dist/storage/db.js +12 -0
- package/dist/storage/db.js.map +1 -1
- package/dist/storage/db.test.d.ts +2 -0
- package/dist/storage/db.test.d.ts.map +1 -0
- package/dist/storage/db.test.js +152 -0
- package/dist/storage/db.test.js.map +1 -0
- package/package.json +7 -6
- package/skill/SKILL.md +131 -206
- package/skill/references/html-template.md +131 -0
- package/skill/references/translation-rules.md +87 -0
- package/dist/translator/prompt.d.ts +0 -21
- package/dist/translator/prompt.d.ts.map +0 -1
- package/dist/translator/prompt.js +0 -117
- package/dist/translator/prompt.js.map +0 -1
- package/dist/translator/translate.d.ts +0 -36
- package/dist/translator/translate.d.ts.map +0 -1
- package/dist/translator/translate.js +0 -73
- package/dist/translator/translate.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/translator/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,UAAU,CAAC;IAChB,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAmFzD;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,EACF,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,WAAW,EAAE,MAAM,GAClB,MAAM,CAyCR"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildPrompt = buildPrompt;
|
|
4
|
-
exports.buildReviewPrompt = buildReviewPrompt;
|
|
5
|
-
function buildPrompt(input) {
|
|
6
|
-
const { git, github, context, dateLabel } = input;
|
|
7
|
-
const contextBlock = context
|
|
8
|
-
? `
|
|
9
|
-
## Company & Role Context
|
|
10
|
-
${context.companyDescription ? `Company: ${context.companyDescription}` : ""}
|
|
11
|
-
${context.managerPriorities ? `Manager priorities: ${context.managerPriorities}` : ""}
|
|
12
|
-
${context.glossary && Object.keys(context.glossary).length > 0
|
|
13
|
-
? `Technical term translations:\n${Object.entries(context.glossary)
|
|
14
|
-
.map(([term, meaning]) => ` - ${term} = ${meaning}`)
|
|
15
|
-
.join("\n")}`
|
|
16
|
-
: ""}
|
|
17
|
-
`.trim()
|
|
18
|
-
: "";
|
|
19
|
-
const commitsBlock = git.commits
|
|
20
|
-
.map((c) => `- [${c.hash}] ${c.message}${c.body ? `\n ${c.body.split("\n")[0]}` : ""}${c.filesChanged.length > 0
|
|
21
|
-
? `\n Files: ${c.filesChanged.slice(0, 8).join(", ")}${c.filesChanged.length > 8 ? ` (+${c.filesChanged.length - 8} more)` : ""}`
|
|
22
|
-
: ""}`)
|
|
23
|
-
.join("\n");
|
|
24
|
-
const githubBlock = github
|
|
25
|
-
? `
|
|
26
|
-
## GitHub Activity
|
|
27
|
-
Repo: ${github.repoFullName}
|
|
28
|
-
|
|
29
|
-
PRs Opened Today: ${github.prsOpened.length > 0 ? github.prsOpened.map((pr) => `#${pr.number} "${pr.title}"${pr.body ? ` — ${pr.body.slice(0, 100)}` : ""}`).join(", ") : "none"}
|
|
30
|
-
|
|
31
|
-
PRs Merged Today: ${github.prsMerged.length > 0 ? github.prsMerged.map((pr) => `#${pr.number} "${pr.title}"`).join(", ") : "none"}
|
|
32
|
-
|
|
33
|
-
PRs Reviewed Today: ${github.prsReviewed.length > 0 ? github.prsReviewed.map((pr) => `#${pr.number} "${pr.title}"`).join(", ") : "none"}
|
|
34
|
-
`.trim()
|
|
35
|
-
: "";
|
|
36
|
-
return `You are a technical writing assistant. Your job is to translate a developer's git activity into plain-English business impact for their daily standup or manager update.
|
|
37
|
-
|
|
38
|
-
${contextBlock}
|
|
39
|
-
|
|
40
|
-
## Git Activity for ${dateLabel}
|
|
41
|
-
Repo: ${git.repoName} (branch: ${git.branch})
|
|
42
|
-
Total files changed: ${git.totalFilesChanged}
|
|
43
|
-
|
|
44
|
-
Commits:
|
|
45
|
-
${commitsBlock || "No commits found"}
|
|
46
|
-
|
|
47
|
-
${githubBlock}
|
|
48
|
-
|
|
49
|
-
## Your Task
|
|
50
|
-
Translate the above technical work into 2–5 bullet points that a non-technical manager or stakeholder can understand.
|
|
51
|
-
|
|
52
|
-
Rules:
|
|
53
|
-
1. Each bullet must describe WHAT was accomplished and WHY it matters to the business. Never just restate the commit message.
|
|
54
|
-
2. Use the glossary to replace jargon (e.g. "RLS" → the meaning provided). If no glossary, infer plain English from context.
|
|
55
|
-
3. If you can't confidently infer business impact, say what was done technically but don't invent a business outcome — use phrasing like "technical foundation work".
|
|
56
|
-
4. For in-progress work (WIP commits, draft PRs), mark as "In progress" with expected outcome.
|
|
57
|
-
5. Group related commits into one bullet if they tell the same story.
|
|
58
|
-
6. Be specific — avoid vague phrases like "improved performance" without a number or context.
|
|
59
|
-
7. Keep each bullet to 1–2 sentences.
|
|
60
|
-
|
|
61
|
-
Respond with ONLY valid JSON matching this schema exactly:
|
|
62
|
-
{
|
|
63
|
-
"items": [
|
|
64
|
-
{
|
|
65
|
-
"status": "done" | "in_progress",
|
|
66
|
-
"summary": "Plain English summary of what was accomplished",
|
|
67
|
-
"impact": "Why this matters — business value, who it unblocks, what risk it reduces. Omit if unknown.",
|
|
68
|
-
"technical_note": "Optional: brief technical aside for a technical reader (1 phrase max)"
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
"files_summary": "Brief description of what areas of the codebase were touched (e.g. 'auth module + database layer')",
|
|
72
|
-
"total_commits": ${git.commits.length},
|
|
73
|
-
"total_files": ${git.totalFilesChanged}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
If there are no commits and no GitHub activity, return:
|
|
77
|
-
{"items": [], "files_summary": "", "total_commits": 0, "total_files": 0}
|
|
78
|
-
`;
|
|
79
|
-
}
|
|
80
|
-
function buildReviewPrompt(entries, context, periodLabel) {
|
|
81
|
-
const contextBlock = context?.companyDescription
|
|
82
|
-
? `Company: ${context.companyDescription}\nManager priorities: ${context.managerPriorities ?? "not specified"}`
|
|
83
|
-
: "";
|
|
84
|
-
const entriesBlock = entries
|
|
85
|
-
.map((e) => `### ${e.date} (${e.repoName}, ${e.totalCommits} commits)\n${e.items.map((i) => `- [${i.status}] ${i.summary}. ${i.impact}`).join("\n")}`)
|
|
86
|
-
.join("\n\n");
|
|
87
|
-
return `You are writing a professional performance review summary for a software engineer.
|
|
88
|
-
|
|
89
|
-
${contextBlock}
|
|
90
|
-
|
|
91
|
-
## Work Log — ${periodLabel}
|
|
92
|
-
|
|
93
|
-
${entriesBlock}
|
|
94
|
-
|
|
95
|
-
## Your Task
|
|
96
|
-
Synthesize the above daily work logs into a structured performance review summary. Group by theme (e.g. "Features shipped", "Reliability & bugs", "Security", "Code review", "Infrastructure").
|
|
97
|
-
|
|
98
|
-
Respond with ONLY valid JSON:
|
|
99
|
-
{
|
|
100
|
-
"period": "${periodLabel}",
|
|
101
|
-
"themes": [
|
|
102
|
-
{
|
|
103
|
-
"name": "Theme name",
|
|
104
|
-
"bullets": ["Specific achievement...", "..."],
|
|
105
|
-
"impact_level": "high" | "medium" | "low"
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
"stats": {
|
|
109
|
-
"total_commits": number,
|
|
110
|
-
"working_days": number,
|
|
111
|
-
"prs_reviewed": number
|
|
112
|
-
},
|
|
113
|
-
"headline": "One sentence that captures the engineer's biggest contribution this period"
|
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 -1,36 +0,0 @@
|
|
|
1
|
-
import { GitSummary } from "../readers/git";
|
|
2
|
-
import { GitHubSummary } from "../readers/github";
|
|
3
|
-
import { UserContext, ImpactItem } from "../storage/db";
|
|
4
|
-
export interface TranslationResult {
|
|
5
|
-
items: ImpactItem[];
|
|
6
|
-
filesSummary: string;
|
|
7
|
-
totalCommits: number;
|
|
8
|
-
totalFiles: number;
|
|
9
|
-
rawJson: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ReviewResult {
|
|
12
|
-
period: string;
|
|
13
|
-
themes: Array<{
|
|
14
|
-
name: string;
|
|
15
|
-
bullets: string[];
|
|
16
|
-
impact_level: "high" | "medium" | "low";
|
|
17
|
-
}>;
|
|
18
|
-
stats: {
|
|
19
|
-
total_commits: number;
|
|
20
|
-
working_days: number;
|
|
21
|
-
prs_reviewed: number;
|
|
22
|
-
};
|
|
23
|
-
headline: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function translateActivity(git: GitSummary, github: GitHubSummary | null, context: UserContext | null, dateLabel: string): Promise<TranslationResult>;
|
|
26
|
-
export declare function generateReview(entries: Array<{
|
|
27
|
-
date: string;
|
|
28
|
-
items: Array<{
|
|
29
|
-
status: string;
|
|
30
|
-
summary: string;
|
|
31
|
-
impact: string;
|
|
32
|
-
}>;
|
|
33
|
-
totalCommits: number;
|
|
34
|
-
repoName: string;
|
|
35
|
-
}>, context: UserContext | null, periodLabel: string): Promise<ReviewResult>;
|
|
36
|
-
//# sourceMappingURL=translate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/translator/translate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;KACzC,CAAC,CAAC;IACH,KAAK,EAAE;QACL,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAYD,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,aAAa,GAAG,IAAI,EAC5B,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,iBAAiB,CAAC,CAmD5B;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,EACF,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,CAAC,CAoBvB"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.translateActivity = translateActivity;
|
|
7
|
-
exports.generateReview = generateReview;
|
|
8
|
-
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
|
|
9
|
-
const prompt_1 = require("./prompt");
|
|
10
|
-
function getAnthropicKey(context) {
|
|
11
|
-
const key = context?.anthropicApiKey || process.env.ANTHROPIC_API_KEY;
|
|
12
|
-
if (!key) {
|
|
13
|
-
throw new Error("No Anthropic API key found. Run `git-impact init` to set one, or set ANTHROPIC_API_KEY env var.");
|
|
14
|
-
}
|
|
15
|
-
return key;
|
|
16
|
-
}
|
|
17
|
-
async function translateActivity(git, github, context, dateLabel) {
|
|
18
|
-
const client = new sdk_1.default({ apiKey: getAnthropicKey(context) });
|
|
19
|
-
const input = { git, github, context, dateLabel };
|
|
20
|
-
const prompt = (0, prompt_1.buildPrompt)(input);
|
|
21
|
-
if (git.commits.length === 0 && !github) {
|
|
22
|
-
return {
|
|
23
|
-
items: [],
|
|
24
|
-
filesSummary: "",
|
|
25
|
-
totalCommits: 0,
|
|
26
|
-
totalFiles: 0,
|
|
27
|
-
rawJson: "{}",
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const message = await client.messages.create({
|
|
31
|
-
model: "claude-sonnet-4-6",
|
|
32
|
-
max_tokens: 1024,
|
|
33
|
-
system: "You are a concise technical writer. Always respond with valid JSON only. No markdown, no explanation outside the JSON object.",
|
|
34
|
-
messages: [{ role: "user", content: prompt }],
|
|
35
|
-
});
|
|
36
|
-
const text = message.content
|
|
37
|
-
.filter((b) => b.type === "text")
|
|
38
|
-
.map((b) => b.text)
|
|
39
|
-
.join("");
|
|
40
|
-
let parsed;
|
|
41
|
-
try {
|
|
42
|
-
// strip possible markdown code fences
|
|
43
|
-
const clean = text.replace(/^```(?:json)?\s*/m, "").replace(/\s*```$/m, "").trim();
|
|
44
|
-
parsed = JSON.parse(clean);
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
throw new Error(`Claude returned invalid JSON:\n${text}`);
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
items: parsed.items ?? [],
|
|
51
|
-
filesSummary: parsed.files_summary ?? "",
|
|
52
|
-
totalCommits: parsed.total_commits ?? git.commits.length,
|
|
53
|
-
totalFiles: parsed.total_files ?? git.totalFilesChanged,
|
|
54
|
-
rawJson: text,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
async function generateReview(entries, context, periodLabel) {
|
|
58
|
-
const client = new sdk_1.default({ apiKey: getAnthropicKey(context) });
|
|
59
|
-
const prompt = (0, prompt_1.buildReviewPrompt)(entries, context, periodLabel);
|
|
60
|
-
const message = await client.messages.create({
|
|
61
|
-
model: "claude-sonnet-4-6",
|
|
62
|
-
max_tokens: 2048,
|
|
63
|
-
system: "You are a professional technical writer. Always respond with valid JSON only. No markdown outside the JSON.",
|
|
64
|
-
messages: [{ role: "user", content: prompt }],
|
|
65
|
-
});
|
|
66
|
-
const text = message.content
|
|
67
|
-
.filter((b) => b.type === "text")
|
|
68
|
-
.map((b) => b.text)
|
|
69
|
-
.join("");
|
|
70
|
-
const clean = text.replace(/^```(?:json)?\s*/m, "").replace(/\s*```$/m, "").trim();
|
|
71
|
-
return JSON.parse(clean);
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=translate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../../src/translator/translate.ts"],"names":[],"mappings":";;;;;AAuCA,8CAwDC;AAED,wCA6BC;AA9HD,4DAA0C;AAI1C,qCAA0E;AAyB1E,SAAS,eAAe,CAAC,OAA2B;IAClD,MAAM,GAAG,GAAG,OAAO,EAAE,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACtE,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAA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