xploitscan-shared-rules 1.25.2 → 1.26.0
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/index.cjs +43 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -826,11 +826,43 @@ function routeForFile(table, filePath) {
|
|
|
826
826
|
// src/intent.ts
|
|
827
827
|
var INTENT_SOURCES = [
|
|
828
828
|
{ test: /(^|\/)\.xploitscan-intent$/i, origin: "declared" },
|
|
829
|
+
// The CLI's --intent flag, passed as a synthetic file so it travels the
|
|
830
|
+
// same path as a real spec. Named for what it is, so a finding reports
|
|
831
|
+
// '--intent says ...' rather than claiming a file exists that does not.
|
|
832
|
+
{ test: /^--intent$/, origin: "declared" },
|
|
833
|
+
// The prompt itself, where a tool preserves it. This is the purest signal
|
|
834
|
+
// there is — it is what the person actually asked for, before anything was
|
|
835
|
+
// generated — and it is the reason this feature can work at all for people
|
|
836
|
+
// who never wrote a README.
|
|
837
|
+
{ test: /(^|\/)\.specstory\/history\/[^/]+\.md$/i, origin: "prompt-history" },
|
|
838
|
+
{ test: /(^|\/)\.bolt\/prompt$/i, origin: "prompt-history" },
|
|
829
839
|
{ test: /(^|\/)(CLAUDE|AGENTS)\.md$/i, origin: "agent-instructions" },
|
|
830
840
|
{ test: /(^|\/)\.cursorrules$/i, origin: "agent-instructions" },
|
|
841
|
+
{ test: /(^|\/)\.windsurfrules$/i, origin: "agent-instructions" },
|
|
831
842
|
{ test: /(^|\/)\.cursor\/rules\/[^/]+\.mdc$/i, origin: "agent-instructions" },
|
|
843
|
+
// 148,992 public repositories carry this file — more than any source here
|
|
844
|
+
// except .cursor/rules, and it is the same kind of document as CLAUDE.md.
|
|
845
|
+
{ test: /(^|\/)\.github\/copilot-instructions\.md$/i, origin: "agent-instructions" },
|
|
832
846
|
{ test: /(^|\/)README(\.md)?$/i, origin: "readme" }
|
|
833
847
|
];
|
|
848
|
+
function extractUserTurns(content) {
|
|
849
|
+
const out = [];
|
|
850
|
+
const lines = content.split("\n");
|
|
851
|
+
let capturing = false;
|
|
852
|
+
for (let i = 0; i < lines.length; i++) {
|
|
853
|
+
const t = lines[i].trim();
|
|
854
|
+
if (/^_\*\*User\*\*_/.test(t)) {
|
|
855
|
+
capturing = true;
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
if (/^_\*\*(Assistant|Agent|System)[^_]*_/.test(t) || t === "---") {
|
|
859
|
+
capturing = false;
|
|
860
|
+
continue;
|
|
861
|
+
}
|
|
862
|
+
if (capturing && t) out.push({ text: t, line: i + 1 });
|
|
863
|
+
}
|
|
864
|
+
return out;
|
|
865
|
+
}
|
|
834
866
|
function isProse(line) {
|
|
835
867
|
const t = line.trim();
|
|
836
868
|
if (t.length < 15 || t.length > 400) return false;
|
|
@@ -848,6 +880,17 @@ function harvestIntent(files) {
|
|
|
848
880
|
for (const file of files) {
|
|
849
881
|
const match = INTENT_SOURCES.find((s) => s.test.test(file.path));
|
|
850
882
|
if (!match) continue;
|
|
883
|
+
if (match.origin === "prompt-history" && /\.specstory\//i.test(file.path)) {
|
|
884
|
+
for (const turn of extractUserTurns(file.content)) {
|
|
885
|
+
for (const sentence of turn.text.split(/(?<=[.!?])\s+(?=[A-Z])/)) {
|
|
886
|
+
const text = clean(sentence).trim();
|
|
887
|
+
if (text.length >= 15) {
|
|
888
|
+
out.push({ text, source: file.path, line: turn.line, origin: match.origin });
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
continue;
|
|
893
|
+
}
|
|
851
894
|
let inFence = false;
|
|
852
895
|
const lines = file.content.split("\n");
|
|
853
896
|
for (let i = 0; i < lines.length; i++) {
|