@memnexus-ai/cli 1.7.61 → 1.7.62
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/dist/commands/commit-context.d.ts +9 -0
- package/dist/commands/commit-context.d.ts.map +1 -0
- package/dist/commands/commit-context.js +210 -0
- package/dist/commands/commit-context.js.map +1 -0
- package/dist/commands/hook.d.ts +12 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +128 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +42 -0
- package/dist/commands/setup.js.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-help.d.ts.map +1 -1
- package/dist/lib/agent-help.js +18 -0
- package/dist/lib/agent-help.js.map +1 -1
- package/dist/lib/commit-context/git-reader.d.ts +14 -0
- package/dist/lib/commit-context/git-reader.d.ts.map +1 -0
- package/dist/lib/commit-context/git-reader.js +84 -0
- package/dist/lib/commit-context/git-reader.js.map +1 -0
- package/dist/lib/commit-context/heuristic-summarizer.d.ts +18 -0
- package/dist/lib/commit-context/heuristic-summarizer.d.ts.map +1 -0
- package/dist/lib/commit-context/heuristic-summarizer.js +124 -0
- package/dist/lib/commit-context/heuristic-summarizer.js.map +1 -0
- package/dist/lib/commit-context/hook-installer.d.ts +18 -0
- package/dist/lib/commit-context/hook-installer.d.ts.map +1 -0
- package/dist/lib/commit-context/hook-installer.js +140 -0
- package/dist/lib/commit-context/hook-installer.js.map +1 -0
- package/dist/lib/commit-context/index.d.ts +12 -0
- package/dist/lib/commit-context/index.d.ts.map +1 -0
- package/dist/lib/commit-context/index.js +47 -0
- package/dist/lib/commit-context/index.js.map +1 -0
- package/dist/lib/commit-context/local-cache.d.ts +35 -0
- package/dist/lib/commit-context/local-cache.d.ts.map +1 -0
- package/dist/lib/commit-context/local-cache.js +161 -0
- package/dist/lib/commit-context/local-cache.js.map +1 -0
- package/dist/lib/commit-context/session-reader.d.ts +27 -0
- package/dist/lib/commit-context/session-reader.d.ts.map +1 -0
- package/dist/lib/commit-context/session-reader.js +208 -0
- package/dist/lib/commit-context/session-reader.js.map +1 -0
- package/dist/lib/commit-context/types.d.ts +61 -0
- package/dist/lib/commit-context/types.d.ts.map +1 -0
- package/dist/lib/commit-context/types.js +6 -0
- package/dist/lib/commit-context/types.js.map +1 -0
- package/dist/lib/setup/rules-templates.d.ts.map +1 -1
- package/dist/lib/setup/rules-templates.js +2 -0
- package/dist/lib/setup/rules-templates.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-reader.d.ts","sourceRoot":"","sources":["../../../src/lib/commit-context/git-reader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM1C;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAOtF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAsB,GAAG,UAAU,CAwDtE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseShortStat = parseShortStat;
|
|
4
|
+
exports.readGitContext = readGitContext;
|
|
5
|
+
/**
|
|
6
|
+
* Git Reader — reads git state for the most recent commit via execFileSync.
|
|
7
|
+
*/
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
function git(args, cwd) {
|
|
10
|
+
return (0, child_process_1.execFileSync)('git', args, { cwd, encoding: 'utf8', timeout: 5000 }).trim();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parse git diff --shortstat output like " 3 files changed, 45 insertions(+), 12 deletions(-)"
|
|
14
|
+
*/
|
|
15
|
+
function parseShortStat(stat) {
|
|
16
|
+
const ins = stat.match(/(\d+) insertion/);
|
|
17
|
+
const del = stat.match(/(\d+) deletion/);
|
|
18
|
+
return {
|
|
19
|
+
insertions: ins ? parseInt(ins[1], 10) : 0,
|
|
20
|
+
deletions: del ? parseInt(del[1], 10) : 0,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Read git context for the most recent commit.
|
|
25
|
+
* @param cwd - Working directory (defaults to process.cwd())
|
|
26
|
+
*/
|
|
27
|
+
function readGitContext(cwd = process.cwd()) {
|
|
28
|
+
const sha = git(['rev-parse', 'HEAD'], cwd);
|
|
29
|
+
const shortSha = sha.slice(0, 7);
|
|
30
|
+
const branch = git(['rev-parse', '--abbrev-ref', 'HEAD'], cwd);
|
|
31
|
+
const message = git(['log', '-1', '--format=%s'], cwd);
|
|
32
|
+
const author = git(['log', '-1', '--format=%an'], cwd);
|
|
33
|
+
const timestamp = git(['log', '-1', '--format=%aI'], cwd);
|
|
34
|
+
// Files changed — may fail on initial commit (no HEAD~1)
|
|
35
|
+
let filesChanged = [];
|
|
36
|
+
try {
|
|
37
|
+
const files = git(['diff', '--name-only', 'HEAD~1', 'HEAD'], cwd);
|
|
38
|
+
filesChanged = files ? files.split('\n').filter(Boolean) : [];
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Initial commit or shallow clone — try diff-tree instead
|
|
42
|
+
try {
|
|
43
|
+
const files = git(['diff-tree', '--no-commit-id', '--name-only', '-r', 'HEAD'], cwd);
|
|
44
|
+
filesChanged = files ? files.split('\n').filter(Boolean) : [];
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
filesChanged = [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Diff stats
|
|
51
|
+
let insertions = 0;
|
|
52
|
+
let deletions = 0;
|
|
53
|
+
try {
|
|
54
|
+
const stat = git(['diff', '--shortstat', 'HEAD~1', 'HEAD'], cwd);
|
|
55
|
+
const parsed = parseShortStat(stat);
|
|
56
|
+
insertions = parsed.insertions;
|
|
57
|
+
deletions = parsed.deletions;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Ignore — stats not critical
|
|
61
|
+
}
|
|
62
|
+
// Detect merge commit (more than one parent)
|
|
63
|
+
let isMergeCommit = false;
|
|
64
|
+
try {
|
|
65
|
+
const parents = git(['rev-parse', 'HEAD^2'], cwd);
|
|
66
|
+
isMergeCommit = parents.length > 0;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Not a merge commit (HEAD^2 doesn't exist)
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
sha,
|
|
73
|
+
shortSha,
|
|
74
|
+
branch,
|
|
75
|
+
message,
|
|
76
|
+
author,
|
|
77
|
+
timestamp,
|
|
78
|
+
filesChanged,
|
|
79
|
+
insertions,
|
|
80
|
+
deletions,
|
|
81
|
+
isMergeCommit,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=git-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-reader.js","sourceRoot":"","sources":["../../../src/lib/commit-context/git-reader.ts"],"names":[],"mappings":";;AAaA,wCAOC;AAMD,wCAwDC;AAlFD;;GAEG;AACH,iDAA6C;AAG7C,SAAS,GAAG,CAAC,IAAc,EAAE,GAAW;IACtC,OAAO,IAAA,4BAAY,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAY;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACzC,OAAO;QACL,UAAU,EAAE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|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristic Summarizer — builds structured markdown content from git + session data.
|
|
3
|
+
*
|
|
4
|
+
* Phase 1: No LLM call. Structured extraction only.
|
|
5
|
+
*/
|
|
6
|
+
import type { GitContext, SessionContext, CommitContextData } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Check if a commit is trivial and should be skipped.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isTrivialCommit(git: GitContext): {
|
|
11
|
+
trivial: boolean;
|
|
12
|
+
reason?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Summarize a commit into a CommitContextData structure.
|
|
16
|
+
*/
|
|
17
|
+
export declare function summarizeCommit(git: GitContext, session?: SessionContext): CommitContextData;
|
|
18
|
+
//# sourceMappingURL=heuristic-summarizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heuristic-summarizer.d.ts","sourceRoot":"","sources":["../../../src/lib/commit-context/heuristic-summarizer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAU7E;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAuBtF;AAwED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,iBAAiB,CA2B5F"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTrivialCommit = isTrivialCommit;
|
|
4
|
+
exports.summarizeCommit = summarizeCommit;
|
|
5
|
+
/** Patterns for trivial commits that should be skipped */
|
|
6
|
+
const TRIVIAL_PATTERNS = [
|
|
7
|
+
/^Merge\s+(branch|pull\s+request|remote)/i,
|
|
8
|
+
/^v?\d+\.\d+\.\d+/, // Version bumps like v1.2.3
|
|
9
|
+
/^\[skip ci\]/i,
|
|
10
|
+
/^wip$/i,
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Check if a commit is trivial and should be skipped.
|
|
14
|
+
*/
|
|
15
|
+
function isTrivialCommit(git) {
|
|
16
|
+
// Merge commits
|
|
17
|
+
if (git.isMergeCommit) {
|
|
18
|
+
return { trivial: true, reason: 'merge commit' };
|
|
19
|
+
}
|
|
20
|
+
// Pattern-based detection
|
|
21
|
+
for (const pattern of TRIVIAL_PATTERNS) {
|
|
22
|
+
if (pattern.test(git.message)) {
|
|
23
|
+
// [skip ci] with <=1 file is trivial; with more files, it's worth capturing
|
|
24
|
+
if (/^\[skip ci\]/i.test(git.message) && git.filesChanged.length > 1) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
return { trivial: true, reason: `matches pattern: ${pattern.source}` };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Bare "wip" with <=1 file
|
|
31
|
+
if (/^wip$/i.test(git.message) && git.filesChanged.length <= 1) {
|
|
32
|
+
return { trivial: true, reason: 'bare wip commit' };
|
|
33
|
+
}
|
|
34
|
+
return { trivial: false };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Build the structured markdown content for a commit context memory.
|
|
38
|
+
*/
|
|
39
|
+
function buildContent(git, session) {
|
|
40
|
+
const lines = [];
|
|
41
|
+
// Header
|
|
42
|
+
lines.push(`## CommitContext: ${git.message} (${git.shortSha})`);
|
|
43
|
+
lines.push('');
|
|
44
|
+
// Metadata
|
|
45
|
+
lines.push(`**Commit:** ${git.sha}`);
|
|
46
|
+
lines.push(`**Branch:** ${git.branch}`);
|
|
47
|
+
if (session) {
|
|
48
|
+
const modelPart = session.model ? ` | **Model:** ${session.model}` : '';
|
|
49
|
+
lines.push(`**Agent:** ${session.agent}${modelPart}`);
|
|
50
|
+
}
|
|
51
|
+
// Files changed
|
|
52
|
+
const changeStats = `+${git.insertions} -${git.deletions}`;
|
|
53
|
+
lines.push(`**Files changed** (${git.filesChanged.length}): ${changeStats}`);
|
|
54
|
+
for (const file of git.filesChanged.slice(0, 20)) {
|
|
55
|
+
lines.push(`- ${file}`);
|
|
56
|
+
}
|
|
57
|
+
if (git.filesChanged.length > 20) {
|
|
58
|
+
lines.push(`- ... and ${git.filesChanged.length - 20} more`);
|
|
59
|
+
}
|
|
60
|
+
// Session info
|
|
61
|
+
if (session && session.totalToolCalls > 0) {
|
|
62
|
+
lines.push('');
|
|
63
|
+
lines.push(`### Tool calls (${session.totalToolCalls})`);
|
|
64
|
+
const toolSummary = session.toolCalls
|
|
65
|
+
.slice(0, 8)
|
|
66
|
+
.map((tc) => `${tc.name}: ${tc.count}`)
|
|
67
|
+
.join(', ');
|
|
68
|
+
lines.push(toolSummary);
|
|
69
|
+
}
|
|
70
|
+
if (session && session.recentPrompts.length > 0) {
|
|
71
|
+
lines.push('');
|
|
72
|
+
lines.push('### Recent prompts');
|
|
73
|
+
for (const prompt of session.recentPrompts) {
|
|
74
|
+
const truncated = prompt.length > 150 ? prompt.slice(0, 150) + '...' : prompt;
|
|
75
|
+
lines.push(`> ${truncated}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (session && session.errors.length > 0) {
|
|
79
|
+
lines.push('');
|
|
80
|
+
lines.push('### Errors encountered');
|
|
81
|
+
for (const err of session.errors) {
|
|
82
|
+
lines.push(`- ${err}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return lines.join('\n');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Build the context field (max 200 chars).
|
|
89
|
+
* Format: "commit:<sha> branch:<branch> agent:<agent>"
|
|
90
|
+
*/
|
|
91
|
+
function buildContextField(git, session) {
|
|
92
|
+
const agent = session?.agent || 'unknown';
|
|
93
|
+
const field = `commit:${git.shortSha} branch:${git.branch} agent:${agent}`;
|
|
94
|
+
return field.slice(0, 200);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Summarize a commit into a CommitContextData structure.
|
|
98
|
+
*/
|
|
99
|
+
function summarizeCommit(git, session) {
|
|
100
|
+
const { trivial, reason } = isTrivialCommit(git);
|
|
101
|
+
if (trivial) {
|
|
102
|
+
return {
|
|
103
|
+
git,
|
|
104
|
+
session,
|
|
105
|
+
content: '',
|
|
106
|
+
contextField: '',
|
|
107
|
+
topics: ['commit-context'],
|
|
108
|
+
skipped: true,
|
|
109
|
+
skipReason: reason,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const content = buildContent(git, session);
|
|
113
|
+
const contextField = buildContextField(git, session);
|
|
114
|
+
const topics = ['commit-context'];
|
|
115
|
+
return {
|
|
116
|
+
git,
|
|
117
|
+
session,
|
|
118
|
+
content,
|
|
119
|
+
contextField,
|
|
120
|
+
topics,
|
|
121
|
+
skipped: false,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=heuristic-summarizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heuristic-summarizer.js","sourceRoot":"","sources":["../../../src/lib/commit-context/heuristic-summarizer.ts"],"names":[],"mappings":";;AAkBA,0CAuBC;AA2ED,0CA2BC;AAxID,0DAA0D;AAC1D,MAAM,gBAAgB,GAAG;IACvB,0CAA0C;IAC1C,kBAAkB,EAAE,4BAA4B;IAChD,eAAe;IACf,QAAQ;CACT,CAAC;AAEF;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAe;IAC7C,gBAAgB;IAChB,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;QACtB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACnD,CAAC;IAED,0BAA0B;IAC1B,KAAK,MAAM,OAAO,IAAI,gBAAgB,EAAE,CAAC;QACvC,IAAI,OAA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E;YACX,YAAY,EAAE,EAAE;YAChB,MAAM,EAAE,CAAC,gBAAgB,CAAC;YAC1B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,MAAM;SACnB,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAElC,OAAO;QACL,GAAG;QACH,OAAO;QACP,OAAO;QACP,YAAY;QACZ,MAAM;QACN,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface HookInstallResult {
|
|
2
|
+
hookPath: string;
|
|
3
|
+
action: 'created' | 'appended' | 'already-installed';
|
|
4
|
+
gitignoreUpdated: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Install the post-commit hook for CommitContext.
|
|
8
|
+
*
|
|
9
|
+
* @param projectRoot - Root of the git project
|
|
10
|
+
* @param dryRun - If true, don't write files
|
|
11
|
+
* @returns Install result
|
|
12
|
+
*/
|
|
13
|
+
export declare function installHook(projectRoot: string, dryRun?: boolean): HookInstallResult;
|
|
14
|
+
/**
|
|
15
|
+
* Check if the post-commit hook is already installed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isHookInstalled(projectRoot: string): boolean;
|
|
18
|
+
//# sourceMappingURL=hook-installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-installer.d.ts","sourceRoot":"","sources":["../../../src/lib/commit-context/hook-installer.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,mBAAmB,CAAC;IACrD,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,GAAE,OAAe,GAAG,iBAAiB,CA0B3F;AA+CD;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAQ5D"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.installHook = installHook;
|
|
37
|
+
exports.isHookInstalled = isHookInstalled;
|
|
38
|
+
/**
|
|
39
|
+
* Hook Installer — installs post-commit git hook for CommitContext capture.
|
|
40
|
+
*
|
|
41
|
+
* Detection order:
|
|
42
|
+
* 1. .husky/ directory → create/append .husky/post-commit
|
|
43
|
+
* 2. .git/hooks/ fallback → create/append .git/hooks/post-commit
|
|
44
|
+
*
|
|
45
|
+
* Always idempotent — checks for existing `mx hook post-commit` line.
|
|
46
|
+
* Also adds .mx/ to .gitignore.
|
|
47
|
+
*/
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
const HOOK_MARKER = 'mx hook post-commit';
|
|
51
|
+
const HOOK_SCRIPT = `#!/bin/sh
|
|
52
|
+
# MemNexus CommitContext — capture commit reasoning automatically
|
|
53
|
+
mx hook post-commit &
|
|
54
|
+
`;
|
|
55
|
+
/**
|
|
56
|
+
* Install the post-commit hook for CommitContext.
|
|
57
|
+
*
|
|
58
|
+
* @param projectRoot - Root of the git project
|
|
59
|
+
* @param dryRun - If true, don't write files
|
|
60
|
+
* @returns Install result
|
|
61
|
+
*/
|
|
62
|
+
function installHook(projectRoot, dryRun = false) {
|
|
63
|
+
const hookPath = resolveHookPath(projectRoot);
|
|
64
|
+
const gitignoreUpdated = ensureGitignore(projectRoot, dryRun);
|
|
65
|
+
// Check if already installed
|
|
66
|
+
if (fs.existsSync(hookPath)) {
|
|
67
|
+
const existing = fs.readFileSync(hookPath, 'utf8');
|
|
68
|
+
if (existing.includes(HOOK_MARKER)) {
|
|
69
|
+
return { hookPath, action: 'already-installed', gitignoreUpdated };
|
|
70
|
+
}
|
|
71
|
+
// Append to existing hook
|
|
72
|
+
if (!dryRun) {
|
|
73
|
+
const appendContent = `\n# MemNexus CommitContext — capture commit reasoning automatically\nmx hook post-commit &\n`;
|
|
74
|
+
fs.appendFileSync(hookPath, appendContent, 'utf8');
|
|
75
|
+
}
|
|
76
|
+
return { hookPath, action: 'appended', gitignoreUpdated };
|
|
77
|
+
}
|
|
78
|
+
// Create new hook file
|
|
79
|
+
if (!dryRun) {
|
|
80
|
+
const dir = path.dirname(hookPath);
|
|
81
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
82
|
+
fs.writeFileSync(hookPath, HOOK_SCRIPT, { mode: 0o755, encoding: 'utf8' });
|
|
83
|
+
}
|
|
84
|
+
return { hookPath, action: 'created', gitignoreUpdated };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Resolve the hook file path (husky or .git/hooks).
|
|
88
|
+
*/
|
|
89
|
+
function resolveHookPath(projectRoot) {
|
|
90
|
+
// Check for husky directory
|
|
91
|
+
const huskyDir = path.join(projectRoot, '.husky');
|
|
92
|
+
if (fs.existsSync(huskyDir) && fs.statSync(huskyDir).isDirectory()) {
|
|
93
|
+
return path.join(huskyDir, 'post-commit');
|
|
94
|
+
}
|
|
95
|
+
// Fall back to .git/hooks
|
|
96
|
+
return path.join(projectRoot, '.git', 'hooks', 'post-commit');
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Ensure .mx/ is in .gitignore.
|
|
100
|
+
* Returns true if .gitignore was updated.
|
|
101
|
+
*/
|
|
102
|
+
function ensureGitignore(projectRoot, dryRun) {
|
|
103
|
+
const gitignorePath = path.join(projectRoot, '.gitignore');
|
|
104
|
+
const entry = '.mx/';
|
|
105
|
+
try {
|
|
106
|
+
if (fs.existsSync(gitignorePath)) {
|
|
107
|
+
const content = fs.readFileSync(gitignorePath, 'utf8');
|
|
108
|
+
if (content.includes(entry)) {
|
|
109
|
+
return false; // Already present
|
|
110
|
+
}
|
|
111
|
+
if (!dryRun) {
|
|
112
|
+
const separator = content.endsWith('\n') ? '' : '\n';
|
|
113
|
+
fs.appendFileSync(gitignorePath, `${separator}${entry}\n`, 'utf8');
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
// No .gitignore — create one
|
|
118
|
+
if (!dryRun) {
|
|
119
|
+
fs.writeFileSync(gitignorePath, `${entry}\n`, 'utf8');
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Check if the post-commit hook is already installed.
|
|
129
|
+
*/
|
|
130
|
+
function isHookInstalled(projectRoot) {
|
|
131
|
+
const hookPath = resolveHookPath(projectRoot);
|
|
132
|
+
try {
|
|
133
|
+
const content = fs.readFileSync(hookPath, 'utf8');
|
|
134
|
+
return content.includes(HOOK_MARKER);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=hook-installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-installer.js","sourceRoot":"","sources":["../../../src/lib/commit-context/hook-installer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,kCA0BC;AAkDD,0CAQC;AArHD;;;;;;;;;GASG;AACH,uCAAyB;AACzB,2CAA6B;AAE7B,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C,MAAM,WAAW,GAAG;;;CAGnB,CAAC;AAQF;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,WAAmB,EAAE,SAAkB,KAAK;IACtE,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE9D,6BAA6B;IAC7B,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAA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M,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAClD,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommitContext — automatic commit context capture.
|
|
3
|
+
*
|
|
4
|
+
* Barrel exports for all commit-context modules.
|
|
5
|
+
*/
|
|
6
|
+
export * from './types';
|
|
7
|
+
export { readGitContext, parseShortStat } from './git-reader';
|
|
8
|
+
export { readSessionContext, findClaudeProjectDir, findLatestSession, parseSessionTail, deriveProjectDirName, } from './session-reader';
|
|
9
|
+
export { summarizeCommit, isTrivialCommit } from './heuristic-summarizer';
|
|
10
|
+
export { writeCache, readCache, listCache, markSynced, markSyncError, getCacheDir, findProjectRoot, } from './local-cache';
|
|
11
|
+
export { installHook, isHookInstalled } from './hook-installer';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/commit-context/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.isHookInstalled = exports.installHook = exports.findProjectRoot = exports.getCacheDir = exports.markSyncError = exports.markSynced = exports.listCache = exports.readCache = exports.writeCache = exports.isTrivialCommit = exports.summarizeCommit = exports.deriveProjectDirName = exports.parseSessionTail = exports.findLatestSession = exports.findClaudeProjectDir = exports.readSessionContext = exports.parseShortStat = exports.readGitContext = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* CommitContext — automatic commit context capture.
|
|
20
|
+
*
|
|
21
|
+
* Barrel exports for all commit-context modules.
|
|
22
|
+
*/
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
24
|
+
var git_reader_1 = require("./git-reader");
|
|
25
|
+
Object.defineProperty(exports, "readGitContext", { enumerable: true, get: function () { return git_reader_1.readGitContext; } });
|
|
26
|
+
Object.defineProperty(exports, "parseShortStat", { enumerable: true, get: function () { return git_reader_1.parseShortStat; } });
|
|
27
|
+
var session_reader_1 = require("./session-reader");
|
|
28
|
+
Object.defineProperty(exports, "readSessionContext", { enumerable: true, get: function () { return session_reader_1.readSessionContext; } });
|
|
29
|
+
Object.defineProperty(exports, "findClaudeProjectDir", { enumerable: true, get: function () { return session_reader_1.findClaudeProjectDir; } });
|
|
30
|
+
Object.defineProperty(exports, "findLatestSession", { enumerable: true, get: function () { return session_reader_1.findLatestSession; } });
|
|
31
|
+
Object.defineProperty(exports, "parseSessionTail", { enumerable: true, get: function () { return session_reader_1.parseSessionTail; } });
|
|
32
|
+
Object.defineProperty(exports, "deriveProjectDirName", { enumerable: true, get: function () { return session_reader_1.deriveProjectDirName; } });
|
|
33
|
+
var heuristic_summarizer_1 = require("./heuristic-summarizer");
|
|
34
|
+
Object.defineProperty(exports, "summarizeCommit", { enumerable: true, get: function () { return heuristic_summarizer_1.summarizeCommit; } });
|
|
35
|
+
Object.defineProperty(exports, "isTrivialCommit", { enumerable: true, get: function () { return heuristic_summarizer_1.isTrivialCommit; } });
|
|
36
|
+
var local_cache_1 = require("./local-cache");
|
|
37
|
+
Object.defineProperty(exports, "writeCache", { enumerable: true, get: function () { return local_cache_1.writeCache; } });
|
|
38
|
+
Object.defineProperty(exports, "readCache", { enumerable: true, get: function () { return local_cache_1.readCache; } });
|
|
39
|
+
Object.defineProperty(exports, "listCache", { enumerable: true, get: function () { return local_cache_1.listCache; } });
|
|
40
|
+
Object.defineProperty(exports, "markSynced", { enumerable: true, get: function () { return local_cache_1.markSynced; } });
|
|
41
|
+
Object.defineProperty(exports, "markSyncError", { enumerable: true, get: function () { return local_cache_1.markSyncError; } });
|
|
42
|
+
Object.defineProperty(exports, "getCacheDir", { enumerable: true, get: function () { return local_cache_1.getCacheDir; } });
|
|
43
|
+
Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return local_cache_1.findProjectRoot; } });
|
|
44
|
+
var hook_installer_1 = require("./hook-installer");
|
|
45
|
+
Object.defineProperty(exports, "installHook", { enumerable: true, get: function () { return hook_installer_1.installHook; } });
|
|
46
|
+
Object.defineProperty(exports, "isHookInstalled", { enumerable: true, get: function () { return hook_installer_1.isHookInstalled; } });
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/commit-context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,0CAAwB;AACxB,2CAA8D;AAArD,4GAAA,cAAc,OAAA;AAAE,4GAAA,cAAc,OAAA;AACvC,mDAM0B;AALxB,oHAAA,kBAAkB,OAAA;AAClB,sHAAA,oBAAoB,OAAA;AACpB,mHAAA,iBAAiB,OAAA;AACjB,kHAAA,gBAAgB,OAAA;AAChB,sHAAA,oBAAoB,OAAA;AAEtB,+DAA0E;AAAjE,uHAAA,eAAe,OAAA;AAAE,uHAAA,eAAe,OAAA;AACzC,6CAQuB;AAPrB,yGAAA,UAAU,OAAA;AACV,wGAAA,SAAS,OAAA;AACT,wGAAA,SAAS,OAAA;AACT,yGAAA,UAAU,OAAA;AACV,4GAAA,aAAa,OAAA;AACb,0GAAA,WAAW,OAAA;AACX,8GAAA,eAAe,OAAA;AAEjB,mDAAgE;AAAvD,6GAAA,WAAW,OAAA;AAAE,iHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CacheEntry } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the cache directory path for a project root.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getCacheDir(projectRoot: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Write a cache entry to disk.
|
|
8
|
+
*/
|
|
9
|
+
export declare function writeCache(projectRoot: string, entry: CacheEntry): void;
|
|
10
|
+
/**
|
|
11
|
+
* Read a cache entry by short SHA.
|
|
12
|
+
* Returns undefined if not found.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readCache(projectRoot: string, shortSha: string): CacheEntry | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* List all cached entries, optionally filtered by sync status.
|
|
17
|
+
* Returns entries sorted by timestamp (newest first).
|
|
18
|
+
*/
|
|
19
|
+
export declare function listCache(projectRoot: string, options?: {
|
|
20
|
+
unsynced?: boolean;
|
|
21
|
+
limit?: number;
|
|
22
|
+
}): CacheEntry[];
|
|
23
|
+
/**
|
|
24
|
+
* Mark a cache entry as synced with a memory ID.
|
|
25
|
+
*/
|
|
26
|
+
export declare function markSynced(projectRoot: string, shortSha: string, memoryId: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Mark a cache entry with a sync error.
|
|
29
|
+
*/
|
|
30
|
+
export declare function markSyncError(projectRoot: string, shortSha: string, error: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Find the git project root by looking for .git directory.
|
|
33
|
+
*/
|
|
34
|
+
export declare function findProjectRoot(cwd?: string): string | undefined;
|
|
35
|
+
//# sourceMappingURL=local-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-cache.d.ts","sourceRoot":"","sources":["../../../src/lib/commit-context/local-cache.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C;;GAEG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEvD;AAkBD;;GAEG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAIvE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAQvF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/C,UAAU,EAAE,CA4Bd;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAQxF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAOxF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,GAAG,SAAS,CAS/E"}
|