aipeek 0.2.4 → 0.2.5
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/{chunk-3NVB3GGE.cjs → chunk-6EZKMGRD.cjs} +21 -50
- package/dist/{chunk-72ZKZ42D.js → chunk-X3HAXWFJ.js} +20 -49
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +8 -2
- package/dist/plugin.js +9 -3
- package/package.json +1 -1
- package/src/server/plugin.ts +19 -62
|
@@ -830,61 +830,29 @@ JS in the page and returns the result \u2014 for anything the typed endpoints ca
|
|
|
830
830
|
aipeek auto-detects errors after HMR and prints them to the terminal \u2014 watch for \`[aipeek]\` messages.
|
|
831
831
|
`;
|
|
832
832
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
const i = t.indexOf("localhost:");
|
|
836
|
-
if (i === -1)
|
|
837
|
-
return t;
|
|
838
|
-
let j = i + "localhost:".length;
|
|
839
|
-
while (j < t.length && t[j] >= "0" && t[j] <= "9") j++;
|
|
840
|
-
return `${t.slice(0, i)}localhost:PORT${t.slice(j)}`;
|
|
841
|
-
}
|
|
842
|
-
function stripBlocks(content, snippet) {
|
|
843
|
-
const known = new Set(snippet.split("\n").map(norm).filter((l) => l.length > 3));
|
|
844
|
-
const lines = content.split("\n");
|
|
845
|
-
const keep = [];
|
|
846
|
-
let inside = false;
|
|
847
|
-
let buf = [];
|
|
848
|
-
let hits = 0;
|
|
849
|
-
const flush = () => {
|
|
850
|
-
if (buf.length && hits / buf.length <= 0.5)
|
|
851
|
-
keep.push(...buf);
|
|
852
|
-
buf = [];
|
|
853
|
-
hits = 0;
|
|
854
|
-
inside = false;
|
|
855
|
-
};
|
|
856
|
-
for (const line of lines) {
|
|
857
|
-
const isKnown = known.has(norm(line));
|
|
858
|
-
if (!inside) {
|
|
859
|
-
if (isKnown) {
|
|
860
|
-
inside = true;
|
|
861
|
-
buf = [line];
|
|
862
|
-
hits = 1;
|
|
863
|
-
} else {
|
|
864
|
-
keep.push(line);
|
|
865
|
-
}
|
|
866
|
-
continue;
|
|
867
|
-
}
|
|
868
|
-
buf.push(line);
|
|
869
|
-
if (isKnown)
|
|
870
|
-
hits++;
|
|
871
|
-
else if (buf.slice(-3).every((l) => !known.has(norm(l))))
|
|
872
|
-
flush();
|
|
873
|
-
}
|
|
874
|
-
flush();
|
|
875
|
-
return keep.join("\n");
|
|
876
|
-
}
|
|
833
|
+
var START_TAG = "<!-- AIPEEK:START -->";
|
|
834
|
+
var END_TAG = "<!-- AIPEEK:END -->";
|
|
877
835
|
function injectClaudeMd(root, port) {
|
|
878
836
|
const path = _path.resolve.call(void 0, root, "CLAUDE.md");
|
|
879
|
-
const
|
|
837
|
+
const block = `${START_TAG}
|
|
838
|
+
${aipeekSnippet(port).trim()}
|
|
839
|
+
${END_TAG}
|
|
840
|
+
`;
|
|
880
841
|
try {
|
|
881
842
|
if (!_fs.existsSync.call(void 0, path)) {
|
|
882
|
-
_fs.writeFileSync.call(void 0, path,
|
|
843
|
+
_fs.writeFileSync.call(void 0, path, block);
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
const content = _fs.readFileSync.call(void 0, path, "utf-8");
|
|
847
|
+
const si = content.indexOf(START_TAG);
|
|
848
|
+
const ei = content.indexOf(END_TAG);
|
|
849
|
+
if (si !== -1 && ei !== -1) {
|
|
850
|
+
_fs.writeFileSync.call(void 0, path, content.slice(0, si) + block.trimEnd() + content.slice(ei + END_TAG.length));
|
|
883
851
|
return;
|
|
884
852
|
}
|
|
885
|
-
const
|
|
886
|
-
_fs.writeFileSync.call(void 0, path, `${
|
|
887
|
-
${
|
|
853
|
+
const sep = content.endsWith("\n") ? "" : "\n";
|
|
854
|
+
_fs.writeFileSync.call(void 0, path, `${content}${sep}
|
|
855
|
+
${block}`);
|
|
888
856
|
} catch (e6) {
|
|
889
857
|
}
|
|
890
858
|
}
|
|
@@ -1201,4 +1169,7 @@ ${result.ui}` : head);
|
|
|
1201
1169
|
|
|
1202
1170
|
|
|
1203
1171
|
|
|
1204
|
-
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
exports.check = check; exports.diffState = diffState; exports.emitSummary = emitSummary; exports.emitCheck = emitCheck; exports.emitDiff = emitDiff; exports.START_TAG = START_TAG; exports.END_TAG = END_TAG; exports.injectClaudeMd = injectClaudeMd; exports.aipeekPlugin = aipeekPlugin;
|
|
@@ -826,61 +826,29 @@ JS in the page and returns the result \u2014 for anything the typed endpoints ca
|
|
|
826
826
|
aipeek auto-detects errors after HMR and prints them to the terminal \u2014 watch for \`[aipeek]\` messages.
|
|
827
827
|
`;
|
|
828
828
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
const i = t.indexOf("localhost:");
|
|
832
|
-
if (i === -1)
|
|
833
|
-
return t;
|
|
834
|
-
let j = i + "localhost:".length;
|
|
835
|
-
while (j < t.length && t[j] >= "0" && t[j] <= "9") j++;
|
|
836
|
-
return `${t.slice(0, i)}localhost:PORT${t.slice(j)}`;
|
|
837
|
-
}
|
|
838
|
-
function stripBlocks(content, snippet) {
|
|
839
|
-
const known = new Set(snippet.split("\n").map(norm).filter((l) => l.length > 3));
|
|
840
|
-
const lines = content.split("\n");
|
|
841
|
-
const keep = [];
|
|
842
|
-
let inside = false;
|
|
843
|
-
let buf = [];
|
|
844
|
-
let hits = 0;
|
|
845
|
-
const flush = () => {
|
|
846
|
-
if (buf.length && hits / buf.length <= 0.5)
|
|
847
|
-
keep.push(...buf);
|
|
848
|
-
buf = [];
|
|
849
|
-
hits = 0;
|
|
850
|
-
inside = false;
|
|
851
|
-
};
|
|
852
|
-
for (const line of lines) {
|
|
853
|
-
const isKnown = known.has(norm(line));
|
|
854
|
-
if (!inside) {
|
|
855
|
-
if (isKnown) {
|
|
856
|
-
inside = true;
|
|
857
|
-
buf = [line];
|
|
858
|
-
hits = 1;
|
|
859
|
-
} else {
|
|
860
|
-
keep.push(line);
|
|
861
|
-
}
|
|
862
|
-
continue;
|
|
863
|
-
}
|
|
864
|
-
buf.push(line);
|
|
865
|
-
if (isKnown)
|
|
866
|
-
hits++;
|
|
867
|
-
else if (buf.slice(-3).every((l) => !known.has(norm(l))))
|
|
868
|
-
flush();
|
|
869
|
-
}
|
|
870
|
-
flush();
|
|
871
|
-
return keep.join("\n");
|
|
872
|
-
}
|
|
829
|
+
var START_TAG = "<!-- AIPEEK:START -->";
|
|
830
|
+
var END_TAG = "<!-- AIPEEK:END -->";
|
|
873
831
|
function injectClaudeMd(root, port) {
|
|
874
832
|
const path = resolve(root, "CLAUDE.md");
|
|
875
|
-
const
|
|
833
|
+
const block = `${START_TAG}
|
|
834
|
+
${aipeekSnippet(port).trim()}
|
|
835
|
+
${END_TAG}
|
|
836
|
+
`;
|
|
876
837
|
try {
|
|
877
838
|
if (!existsSync(path)) {
|
|
878
|
-
writeFileSync(path,
|
|
839
|
+
writeFileSync(path, block);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
const content = readFileSync(path, "utf-8");
|
|
843
|
+
const si = content.indexOf(START_TAG);
|
|
844
|
+
const ei = content.indexOf(END_TAG);
|
|
845
|
+
if (si !== -1 && ei !== -1) {
|
|
846
|
+
writeFileSync(path, content.slice(0, si) + block.trimEnd() + content.slice(ei + END_TAG.length));
|
|
879
847
|
return;
|
|
880
848
|
}
|
|
881
|
-
const
|
|
882
|
-
writeFileSync(path, `${
|
|
883
|
-
${
|
|
849
|
+
const sep = content.endsWith("\n") ? "" : "\n";
|
|
850
|
+
writeFileSync(path, `${content}${sep}
|
|
851
|
+
${block}`);
|
|
884
852
|
} catch {
|
|
885
853
|
}
|
|
886
854
|
}
|
|
@@ -1196,5 +1164,8 @@ export {
|
|
|
1196
1164
|
emitSummary,
|
|
1197
1165
|
emitCheck,
|
|
1198
1166
|
emitDiff,
|
|
1167
|
+
START_TAG,
|
|
1168
|
+
END_TAG,
|
|
1169
|
+
injectClaudeMd,
|
|
1199
1170
|
aipeekPlugin
|
|
1200
1171
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk6EZKMGRDcjs = require('./chunk-6EZKMGRD.cjs');
|
|
9
9
|
require('./chunk-Z2Y65YOY.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
@@ -14,4 +14,4 @@ require('./chunk-Z2Y65YOY.cjs');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
exports.aipeekPlugin =
|
|
17
|
+
exports.aipeekPlugin = _chunk6EZKMGRDcjs.aipeekPlugin; exports.check = _chunk6EZKMGRDcjs.check; exports.diffState = _chunk6EZKMGRDcjs.diffState; exports.emitCheck = _chunk6EZKMGRDcjs.emitCheck; exports.emitDiff = _chunk6EZKMGRDcjs.emitDiff; exports.emitSummary = _chunk6EZKMGRDcjs.emitSummary;
|
package/dist/index.js
CHANGED
package/dist/plugin.cjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk6EZKMGRDcjs = require('./chunk-6EZKMGRD.cjs');
|
|
4
7
|
require('./chunk-Z2Y65YOY.cjs');
|
|
5
8
|
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.END_TAG = _chunk6EZKMGRDcjs.END_TAG; exports.START_TAG = _chunk6EZKMGRDcjs.START_TAG; exports.aipeekPlugin = _chunk6EZKMGRDcjs.aipeekPlugin; exports.injectClaudeMd = _chunk6EZKMGRDcjs.injectClaudeMd;
|
package/dist/plugin.js
CHANGED
package/package.json
CHANGED
package/src/server/plugin.ts
CHANGED
|
@@ -107,73 +107,30 @@ aipeek auto-detects errors after HMR and prints them to the terminal — watch f
|
|
|
107
107
|
`
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return `${t.slice(0, i)}localhost:PORT${t.slice(j)}`
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// strip every existing aipeek block by simulating a human reading line-by-line:
|
|
122
|
-
// scan downward; once enough recent lines belong to the snippet we're INSIDE a
|
|
123
|
-
// block; once they stop belonging we're OUTSIDE again. A run whose lines are
|
|
124
|
-
// >50% snippet-content is dropped. Content-fuzzy — survives wording/port edits.
|
|
125
|
-
function stripBlocks(content: string, snippet: string): string {
|
|
126
|
-
const known = new Set(snippet.split('\n').map(norm).filter(l => l.length > 3))
|
|
127
|
-
const lines = content.split('\n')
|
|
128
|
-
const keep: string[] = []
|
|
129
|
-
let inside = false
|
|
130
|
-
let buf: string[] = []
|
|
131
|
-
let hits = 0
|
|
132
|
-
|
|
133
|
-
const flush = () => {
|
|
134
|
-
// settle the buffered run: drop it if it reads as snippet, else keep it
|
|
135
|
-
if (buf.length && hits / buf.length <= 0.5)
|
|
136
|
-
keep.push(...buf)
|
|
137
|
-
buf = []
|
|
138
|
-
hits = 0
|
|
139
|
-
inside = false
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
for (const line of lines) {
|
|
143
|
-
const isKnown = known.has(norm(line))
|
|
144
|
-
if (!inside) {
|
|
145
|
-
if (isKnown) {
|
|
146
|
-
inside = true
|
|
147
|
-
buf = [line]
|
|
148
|
-
hits = 1
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
keep.push(line)
|
|
152
|
-
}
|
|
153
|
-
continue
|
|
154
|
-
}
|
|
155
|
-
// INSIDE: keep accumulating until we drift away from the snippet
|
|
156
|
-
buf.push(line)
|
|
157
|
-
if (isKnown)
|
|
158
|
-
hits++
|
|
159
|
-
// a run of unknown lines means the block ended — settle it
|
|
160
|
-
else if (buf.slice(-3).every(l => !known.has(norm(l))))
|
|
161
|
-
flush()
|
|
162
|
-
}
|
|
163
|
-
flush()
|
|
164
|
-
return keep.join('\n')
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function injectClaudeMd(root: string, port: number) {
|
|
110
|
+
export const START_TAG = '<!-- AIPEEK:START -->'
|
|
111
|
+
export const END_TAG = '<!-- AIPEEK:END -->'
|
|
112
|
+
|
|
113
|
+
// Marker-based injection — the block lives between START_TAG and END_TAG, so
|
|
114
|
+
// re-injection is a deterministic splice (find markers, replace between) rather
|
|
115
|
+
// than fuzzy line matching. New file → write markers + snippet. Existing markers
|
|
116
|
+
// → replace their contents. No markers yet → append a fresh marked block.
|
|
117
|
+
export function injectClaudeMd(root: string, port: number) {
|
|
168
118
|
const path = resolve(root, 'CLAUDE.md')
|
|
169
|
-
const
|
|
119
|
+
const block = `${START_TAG}\n${aipeekSnippet(port).trim()}\n${END_TAG}\n`
|
|
170
120
|
try {
|
|
171
121
|
if (!existsSync(path)) {
|
|
172
|
-
writeFileSync(path,
|
|
122
|
+
writeFileSync(path, block)
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
const content = readFileSync(path, 'utf-8')
|
|
126
|
+
const si = content.indexOf(START_TAG)
|
|
127
|
+
const ei = content.indexOf(END_TAG)
|
|
128
|
+
if (si !== -1 && ei !== -1) {
|
|
129
|
+
writeFileSync(path, content.slice(0, si) + block.trimEnd() + content.slice(ei + END_TAG.length))
|
|
173
130
|
return
|
|
174
131
|
}
|
|
175
|
-
const
|
|
176
|
-
writeFileSync(path, `${
|
|
132
|
+
const sep = content.endsWith('\n') ? '' : '\n'
|
|
133
|
+
writeFileSync(path, `${content}${sep}\n${block}`)
|
|
177
134
|
}
|
|
178
135
|
catch {}
|
|
179
136
|
}
|