@mnemonik/shared 7.57.4 → 7.57.7
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.
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* Mechanism: snapshot the set of dirty paths (`git status --porcelain -uall`)
|
|
14
14
|
* at session start, and after each shell call diff the current set against the
|
|
15
15
|
* snapshot. Paths that are newly dirty were written between the two
|
|
16
|
-
* observations
|
|
17
|
-
* additions count — a commit or stash SHRINKS the set,
|
|
18
|
-
* new work. Edit tool writes are unioned into the
|
|
19
|
-
* handler so they are never re-credited to the
|
|
16
|
+
* observations. The caller reports those paths, then adds only confirmed paths
|
|
17
|
+
* to the snapshot. Only additions count — a commit or stash SHRINKS the set,
|
|
18
|
+
* and saving work is not new work. Edit tool writes are unioned into the
|
|
19
|
+
* snapshot by each host's edit handler so they are never re-credited to the
|
|
20
|
+
* next shell call.
|
|
20
21
|
*
|
|
21
22
|
* Host-agnostic by construction: the caller owns session identity and passes
|
|
22
23
|
* the absolute path of its own private snapshot file. An empty `snapshotFile`
|
|
@@ -48,8 +49,9 @@ export declare function listGitDirtyPaths(cwd: string): {
|
|
|
48
49
|
export declare function captureGitDirtyBaseline(snapshotFile: string, cwd: string): void;
|
|
49
50
|
/**
|
|
50
51
|
* After a shell call: paths newly dirty since the last observation, capped.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
52
|
+
* Leaves additions pending until the caller confirms them with
|
|
53
|
+
* addPathsToGitDirtySnapshot. Without a usable baseline it establishes one and
|
|
54
|
+
* reports nothing — degrading toward silence, never toward a false edit.
|
|
53
55
|
*/
|
|
54
56
|
export declare function diffGitDirtySnapshot(snapshotFile: string, cwd: string): string[];
|
|
55
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitEditDetector.d.ts","sourceRoot":"","sources":["../src/gitEditDetector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gitEditDetector.d.ts","sourceRoot":"","sources":["../src/gitEditDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAsCH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAuBvF;AA0BD,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAK/E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBhF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAQtF"}
|
package/dist/gitEditDetector.js
CHANGED
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* Mechanism: snapshot the set of dirty paths (`git status --porcelain -uall`)
|
|
14
14
|
* at session start, and after each shell call diff the current set against the
|
|
15
15
|
* snapshot. Paths that are newly dirty were written between the two
|
|
16
|
-
* observations
|
|
17
|
-
* additions count — a commit or stash SHRINKS the set,
|
|
18
|
-
* new work. Edit tool writes are unioned into the
|
|
19
|
-
* handler so they are never re-credited to the
|
|
16
|
+
* observations. The caller reports those paths, then adds only confirmed paths
|
|
17
|
+
* to the snapshot. Only additions count — a commit or stash SHRINKS the set,
|
|
18
|
+
* and saving work is not new work. Edit tool writes are unioned into the
|
|
19
|
+
* snapshot by each host's edit handler so they are never re-credited to the
|
|
20
|
+
* next shell call.
|
|
20
21
|
*
|
|
21
22
|
* Host-agnostic by construction: the caller owns session identity and passes
|
|
22
23
|
* the absolute path of its own private snapshot file. An empty `snapshotFile`
|
|
@@ -128,8 +129,9 @@ export function captureGitDirtyBaseline(snapshotFile, cwd) {
|
|
|
128
129
|
}
|
|
129
130
|
/**
|
|
130
131
|
* After a shell call: paths newly dirty since the last observation, capped.
|
|
131
|
-
*
|
|
132
|
-
*
|
|
132
|
+
* Leaves additions pending until the caller confirms them with
|
|
133
|
+
* addPathsToGitDirtySnapshot. Without a usable baseline it establishes one and
|
|
134
|
+
* reports nothing — degrading toward silence, never toward a false edit.
|
|
133
135
|
*/
|
|
134
136
|
export function diffGitDirtySnapshot(snapshotFile, cwd) {
|
|
135
137
|
if (!snapshotFile)
|
|
@@ -138,11 +140,13 @@ export function diffGitDirtySnapshot(snapshotFile, cwd) {
|
|
|
138
140
|
if (!current)
|
|
139
141
|
return [];
|
|
140
142
|
const baseline = readSnapshot(snapshotFile);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
if (!baseline || baseline.root !== current.root) {
|
|
144
|
+
writeSnapshot(snapshotFile, current.root, current.paths);
|
|
143
145
|
return [];
|
|
146
|
+
}
|
|
144
147
|
const known = new Set(baseline.paths);
|
|
145
|
-
const additions = current.paths.filter((
|
|
148
|
+
const additions = current.paths.filter((path) => !known.has(path));
|
|
149
|
+
writeSnapshot(snapshotFile, current.root, current.paths.filter((path) => known.has(path)));
|
|
146
150
|
return additions.slice(0, MAX_REPORTED_PATHS_PER_CALL);
|
|
147
151
|
}
|
|
148
152
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitEditDetector.js","sourceRoot":"","sources":["../src/gitEditDetector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gitEditDetector.js","sourceRoot":"","sources":["../src/gitEditDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,IAAI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C,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACnE,aAAa,CACX,YAAY,EACZ,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAChD,CAAC;IACF,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,YAAoB,EAAE,KAAe;IAC9E,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAChD,MAAM,QAAQ,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAC5C,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACnC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;AAChF,CAAC"}
|
package/package.json
CHANGED
package/src/gitEditDetector.ts
CHANGED
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* Mechanism: snapshot the set of dirty paths (`git status --porcelain -uall`)
|
|
14
14
|
* at session start, and after each shell call diff the current set against the
|
|
15
15
|
* snapshot. Paths that are newly dirty were written between the two
|
|
16
|
-
* observations
|
|
17
|
-
* additions count — a commit or stash SHRINKS the set,
|
|
18
|
-
* new work. Edit tool writes are unioned into the
|
|
19
|
-
* handler so they are never re-credited to the
|
|
16
|
+
* observations. The caller reports those paths, then adds only confirmed paths
|
|
17
|
+
* to the snapshot. Only additions count — a commit or stash SHRINKS the set,
|
|
18
|
+
* and saving work is not new work. Edit tool writes are unioned into the
|
|
19
|
+
* snapshot by each host's edit handler so they are never re-credited to the
|
|
20
|
+
* next shell call.
|
|
20
21
|
*
|
|
21
22
|
* Host-agnostic by construction: the caller owns session identity and passes
|
|
22
23
|
* the absolute path of its own private snapshot file. An empty `snapshotFile`
|
|
@@ -136,18 +137,26 @@ export function captureGitDirtyBaseline(snapshotFile: string, cwd: string): void
|
|
|
136
137
|
|
|
137
138
|
/**
|
|
138
139
|
* After a shell call: paths newly dirty since the last observation, capped.
|
|
139
|
-
*
|
|
140
|
-
*
|
|
140
|
+
* Leaves additions pending until the caller confirms them with
|
|
141
|
+
* addPathsToGitDirtySnapshot. Without a usable baseline it establishes one and
|
|
142
|
+
* reports nothing — degrading toward silence, never toward a false edit.
|
|
141
143
|
*/
|
|
142
144
|
export function diffGitDirtySnapshot(snapshotFile: string, cwd: string): string[] {
|
|
143
145
|
if (!snapshotFile) return [];
|
|
144
146
|
const current = listGitDirtyPaths(cwd);
|
|
145
147
|
if (!current) return [];
|
|
146
148
|
const baseline = readSnapshot(snapshotFile);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
if (!baseline || baseline.root !== current.root) {
|
|
150
|
+
writeSnapshot(snapshotFile, current.root, current.paths);
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
149
153
|
const known = new Set(baseline.paths);
|
|
150
|
-
const additions = current.paths.filter((
|
|
154
|
+
const additions = current.paths.filter((path) => !known.has(path));
|
|
155
|
+
writeSnapshot(
|
|
156
|
+
snapshotFile,
|
|
157
|
+
current.root,
|
|
158
|
+
current.paths.filter((path) => known.has(path))
|
|
159
|
+
);
|
|
151
160
|
return additions.slice(0, MAX_REPORTED_PATHS_PER_CALL);
|
|
152
161
|
}
|
|
153
162
|
|