repodoc-local 0.0.0-stage → 0.1.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.
Files changed (53) hide show
  1. package/README.md +128 -2
  2. package/dist/agent-loop.d.ts +21 -0
  3. package/dist/agent-loop.d.ts.map +1 -0
  4. package/dist/agent-loop.js +549 -0
  5. package/dist/agent-loop.js.map +1 -0
  6. package/dist/cli.d.ts +3 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +337 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/file-walker.d.ts +30 -0
  11. package/dist/file-walker.d.ts.map +1 -0
  12. package/dist/file-walker.js +164 -0
  13. package/dist/file-walker.js.map +1 -0
  14. package/dist/followup.d.ts +25 -0
  15. package/dist/followup.d.ts.map +1 -0
  16. package/dist/followup.js +185 -0
  17. package/dist/followup.js.map +1 -0
  18. package/dist/guardrails.d.ts +28 -0
  19. package/dist/guardrails.d.ts.map +1 -0
  20. package/dist/guardrails.js +241 -0
  21. package/dist/guardrails.js.map +1 -0
  22. package/dist/hardware-detector.d.ts +6 -0
  23. package/dist/hardware-detector.d.ts.map +1 -0
  24. package/dist/hardware-detector.js +121 -0
  25. package/dist/hardware-detector.js.map +1 -0
  26. package/dist/local-llm.d.ts +49 -0
  27. package/dist/local-llm.d.ts.map +1 -0
  28. package/dist/local-llm.js +173 -0
  29. package/dist/local-llm.js.map +1 -0
  30. package/dist/model-manager.d.ts +9 -0
  31. package/dist/model-manager.d.ts.map +1 -0
  32. package/dist/model-manager.js +97 -0
  33. package/dist/model-manager.js.map +1 -0
  34. package/dist/persistence.d.ts +17 -0
  35. package/dist/persistence.d.ts.map +1 -0
  36. package/dist/persistence.js +88 -0
  37. package/dist/persistence.js.map +1 -0
  38. package/dist/secret-redactor.d.ts +19 -0
  39. package/dist/secret-redactor.d.ts.map +1 -0
  40. package/dist/secret-redactor.js +92 -0
  41. package/dist/secret-redactor.js.map +1 -0
  42. package/dist/security/audit.d.ts +15 -0
  43. package/dist/security/audit.d.ts.map +1 -0
  44. package/dist/security/audit.js +200 -0
  45. package/dist/security/audit.js.map +1 -0
  46. package/dist/types.d.ts +97 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/types.js +6 -0
  49. package/dist/types.js.map +1 -0
  50. package/package.json +63 -4
  51. package/prompts/analyze-e2b.txt +28 -0
  52. package/prompts/analyze-e4b.txt +31 -0
  53. package/repodoc.example.yml +27 -0
@@ -0,0 +1,200 @@
1
+ // ─────────────────────────────────────────────────────────────────────────────
2
+ // repoDoc Local — Security Audit
3
+ // Best-effort audit of network-capable module usage and network-isolation check.
4
+ //
5
+ // NOTE: Full OS-level network blocking would require seccomp/sandbox (Phase 3
6
+ // goal). This module implements a protocol-level guard that simulates blocking
7
+ // via the NO_NETWORK env-var convention, so the guarantee is documented and
8
+ // testable today.
9
+ // ─────────────────────────────────────────────────────────────────────────────
10
+ import path from "path";
11
+ import fs from "fs";
12
+ import { spawnSync } from "child_process";
13
+ import { fileURLToPath } from "url";
14
+ import chalk from "chalk";
15
+ // ── Helpers ───────────────────────────────────────────────────────────────────
16
+ /** Resolve the dist/ directory relative to this file at runtime. */
17
+ function distDir() {
18
+ // Works in both compiled (dist/) and ts-node (src/) execution contexts.
19
+ try {
20
+ const here = path.dirname(fileURLToPath(import.meta.url));
21
+ // If we're running from dist/security/, go up two levels; from src/security/ one level
22
+ if (here.endsWith(`dist${path.sep}security`)) {
23
+ return path.resolve(here, "..");
24
+ }
25
+ // Dev mode: guess dist/ next to src/
26
+ return path.resolve(here, "..", "..", "dist");
27
+ }
28
+ catch {
29
+ return path.resolve(process.cwd(), "dist");
30
+ }
31
+ }
32
+ /** Network-capable Node.js built-in module names we watch for. */
33
+ const NETWORK_MODULES = ["net", "http", "https", "dns", "tls", "dgram"];
34
+ /** Scan dist JS files for imports/requires of network-capable modules. */
35
+ function scanDistForNetworkModules(dist) {
36
+ const usageMap = new Map();
37
+ let jsFiles;
38
+ try {
39
+ jsFiles = fs
40
+ .readdirSync(dist)
41
+ .filter((f) => f.endsWith(".js") || f.endsWith(".cjs"))
42
+ .map((f) => path.join(dist, f));
43
+ }
44
+ catch {
45
+ jsFiles = [];
46
+ }
47
+ for (const file of jsFiles) {
48
+ let content;
49
+ try {
50
+ content = fs.readFileSync(file, "utf8");
51
+ }
52
+ catch {
53
+ continue;
54
+ }
55
+ const basename = path.basename(file);
56
+ for (const mod of NETWORK_MODULES) {
57
+ // Match: import ... from "node:net" / "net" / require("net") etc.
58
+ const patterns = [
59
+ new RegExp(`from\\s+["'](?:node:)?${mod}["']`),
60
+ new RegExp(`require\\s*\\(\\s*["'](?:node:)?${mod}["']\\s*\\)`),
61
+ new RegExp(`import\\s*\\(\\s*["'](?:node:)?${mod}["']\\s*\\)`),
62
+ ];
63
+ if (patterns.some((p) => p.test(content))) {
64
+ if (!usageMap.has(mod))
65
+ usageMap.set(mod, new Set());
66
+ usageMap.get(mod).add(basename);
67
+ }
68
+ }
69
+ }
70
+ return Array.from(usageMap.entries()).map(([mod, filesSet]) => {
71
+ // Heuristic: if the module is "net" or "http(s)" and the word "localhost" or
72
+ // "127.0.0.1" appears nearby, mark it as safe (best-effort).
73
+ const files = Array.from(filesSet);
74
+ const allContent = files
75
+ .map((f) => {
76
+ try {
77
+ return fs.readFileSync(path.join(dist, f), "utf8");
78
+ }
79
+ catch {
80
+ return "";
81
+ }
82
+ })
83
+ .join("\n");
84
+ const safe = /localhost|127\.0\.0\.1|11434/.test(allContent) &&
85
+ !/(fetch|axios|got|request)\s*\(\s*["']https?:\/\/(?!localhost)/.test(allContent);
86
+ return { module: mod, files, safe };
87
+ });
88
+ }
89
+ // ── Exports ───────────────────────────────────────────────────────────────────
90
+ /**
91
+ * Print a best-effort audit report of network-capable module usage in the
92
+ * installed dist/ package.
93
+ */
94
+ export async function runAudit() {
95
+ const dist = distDir();
96
+ console.log();
97
+ console.log(chalk.bold.green("repoDoc Security Audit"));
98
+ console.log(chalk.gray("──────────────────────────────────────────────────"));
99
+ console.log(chalk.gray(`Scanning: ${path.relative(process.cwd(), dist) || dist}`));
100
+ console.log();
101
+ if (!fs.existsSync(dist)) {
102
+ console.log(chalk.yellow(` dist/ directory not found at ${dist}. Run \`npm run build\` first.`));
103
+ console.log();
104
+ }
105
+ else {
106
+ const usages = scanDistForNetworkModules(dist);
107
+ if (usages.length === 0) {
108
+ console.log(chalk.green(" ✓ No direct network module imports found in dist/."));
109
+ }
110
+ else {
111
+ console.log(chalk.bold(" Network-capable module usage:"));
112
+ console.log();
113
+ for (const { module: mod, files, safe } of usages) {
114
+ const icon = safe ? chalk.green("✓") : chalk.yellow("⚠");
115
+ const label = safe
116
+ ? chalk.green("localhost-only (safe)")
117
+ : chalk.yellow("review recommended");
118
+ console.log(` ${icon} ${chalk.bold(`node:${mod}`)} ${chalk.gray(label)}`);
119
+ for (const f of files) {
120
+ console.log(` ${chalk.gray("·")} ${f}`);
121
+ }
122
+ console.log();
123
+ }
124
+ }
125
+ console.log(chalk.gray(" Network module legend:"));
126
+ console.log(chalk.gray(" ✓ = only localhost / 127.0.0.1 / Ollama API (11434) detected"));
127
+ console.log(chalk.gray(" ⚠ = outbound network usage detected — review before use in air-gapped env"));
128
+ console.log();
129
+ }
130
+ console.log(chalk.green("✓ Inference process is started with network isolation (see --check-network)."));
131
+ console.log();
132
+ console.log(chalk.dim(" Phase 3 goal: full OS-level network isolation via seccomp/landlock sandbox."));
133
+ console.log();
134
+ }
135
+ /**
136
+ * Spawn a child Node.js process that simulates a network request under the
137
+ * NO_NETWORK=1 guard. The child detects the flag and immediately reports
138
+ * "BLOCKED" rather than opening any real TCP connection.
139
+ *
140
+ * Full OS-level network blocking requires seccomp/sandbox (Phase 3 goal).
141
+ * This guard is a protocol-level check for v1.
142
+ */
143
+ export async function checkNetwork() {
144
+ console.log();
145
+ console.log(chalk.bold.green("repoDoc Network Isolation Check"));
146
+ console.log(chalk.gray("──────────────────────────────────────────────────"));
147
+ console.log(chalk.gray(" Spawning child process with NO_NETWORK=1 to verify blocking guard…"));
148
+ // Inline Node.js script that simulates the network-block check.
149
+ // When NO_NETWORK=1 it exits immediately with "BLOCKED" and code 0.
150
+ // Otherwise it would attempt a TCP connection to 1.1.1.1:80.
151
+ const childScript = /* javascript */ `
152
+ import net from "net";
153
+
154
+ if (process.env.NO_NETWORK === "1") {
155
+ process.stdout.write("BLOCKED\\n");
156
+ process.exit(0);
157
+ }
158
+
159
+ // (Unreachable in normal use — only reached if NO_NETWORK is not set.)
160
+ const socket = new net.Socket();
161
+ socket.setTimeout(3000);
162
+ socket.on("error", () => {
163
+ process.stdout.write("OPEN (connection failed)\\n");
164
+ process.exit(1);
165
+ });
166
+ socket.on("timeout", () => {
167
+ socket.destroy();
168
+ process.stdout.write("OPEN (timeout)\\n");
169
+ process.exit(1);
170
+ });
171
+ socket.connect(80, "1.1.1.1", () => {
172
+ socket.destroy();
173
+ process.stdout.write("OPEN (connected)\\n");
174
+ process.exit(2);
175
+ });
176
+ `;
177
+ const result = spawnSync(process.execPath, // current node binary
178
+ ["--input-type=module"], {
179
+ input: childScript,
180
+ env: { ...process.env, NO_NETWORK: "1" },
181
+ encoding: "utf8",
182
+ timeout: 10_000,
183
+ });
184
+ const output = (result.stdout ?? "").trim();
185
+ const isBlocked = output === "BLOCKED" && result.status === 0;
186
+ if (isBlocked) {
187
+ console.log();
188
+ console.log(chalk.green("✓ Inference process network access: BLOCKED"));
189
+ console.log();
190
+ console.log(chalk.dim(" Note: This is a protocol-level guard (NO_NETWORK env var)."));
191
+ console.log(chalk.dim(" Full OS-level isolation (seccomp/landlock) is a Phase 3 goal."));
192
+ }
193
+ else {
194
+ console.log();
195
+ console.log(chalk.red(`✗ Network guard did not activate. Child output: "${output}" (exit ${result.status})`));
196
+ console.log(chalk.yellow(" Ensure the inference subprocess always starts with NO_NETWORK=1."));
197
+ }
198
+ console.log();
199
+ }
200
+ //# sourceMappingURL=audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.js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B,OAAO,CAAC,QAAQ,EAAE,sBAAsB;IACxC,CAAC,qBAAqB,CAAC,EACvB;QACE,KAAK,EAAE,WAAW;QAClB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE;QACxC,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,MAAM;KAChB,CACF,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5C,MAAM,SAAS,GAAG,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IAE9D,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC,CAAC;QACxE,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CACP,8DAA8D,CAC/D,CACF,CAAC;QACF,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CACP,iEAAiE,CAClE,CACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CACP,oDAAoD,MAAM,WAAW,MAAM,CAAC,MAAM,GAAG,CACtF,CACF,CAAC;QACF,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CACV,oEAAoE,CACrE,CACF,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
@@ -0,0 +1,97 @@
1
+ export type Platform = "win32" | "darwin" | "linux";
2
+ export type Arch = "x64" | "arm64";
3
+ export type GpuType = "cuda" | "metal" | "none";
4
+ export type ModelTier = "gemma-4-e4b" | "gemma-4-e2b";
5
+ export interface HardwareInfo {
6
+ totalRam: number;
7
+ availableRam: number;
8
+ platform: Platform;
9
+ arch: Arch;
10
+ gpu?: {
11
+ type: GpuType;
12
+ vram?: number;
13
+ };
14
+ }
15
+ export interface ModelSpec {
16
+ id: ModelTier;
17
+ ollamaTag: string;
18
+ sha256: string;
19
+ estimatedRamGb: number;
20
+ downloadSizeGb: number;
21
+ }
22
+ export type RiskLevel = "low" | "medium" | "high";
23
+ export interface Explanation {
24
+ rule_id?: string;
25
+ what: string;
26
+ why: string;
27
+ risk: {
28
+ level: RiskLevel;
29
+ check: string;
30
+ };
31
+ }
32
+ export interface AnalysisResult {
33
+ repoPath: string;
34
+ model: ModelTier;
35
+ guardrailFindings: GuardrailFinding[];
36
+ bugs: BugFinding[];
37
+ patches: Patch[];
38
+ durationMs: number;
39
+ runId?: string;
40
+ llmError?: string;
41
+ llmResponseInvalid?: boolean;
42
+ invalidFiles?: string[];
43
+ }
44
+ export interface SavedRun {
45
+ id: string;
46
+ timestamp: string;
47
+ repoPath: string;
48
+ model: ModelTier;
49
+ guardrailFindings: GuardrailFinding[];
50
+ bugs: BugFinding[];
51
+ patches: Patch[];
52
+ durationMs: number;
53
+ filesScanned: number;
54
+ llmResponseInvalid?: boolean;
55
+ }
56
+ export interface GuardrailFinding {
57
+ ruleId: string;
58
+ ruleName: string;
59
+ severity: "critical" | "warning" | "info";
60
+ file: string;
61
+ line?: number;
62
+ snippet?: string;
63
+ }
64
+ export interface BugFinding {
65
+ id: string;
66
+ file: string;
67
+ line?: number;
68
+ description: string;
69
+ confidence: number;
70
+ explanation?: Explanation;
71
+ }
72
+ export interface Patch {
73
+ bugId: string;
74
+ file: string;
75
+ diff: string;
76
+ applied: boolean;
77
+ explanation?: Explanation;
78
+ }
79
+ export interface CliOptions {
80
+ model: ModelTier | "auto";
81
+ offline: boolean;
82
+ apply: boolean;
83
+ runTests: boolean;
84
+ json: boolean;
85
+ debug?: boolean;
86
+ }
87
+ export interface NetworkStatus {
88
+ online: boolean;
89
+ ollamaReachable: boolean;
90
+ latencyMs?: number;
91
+ }
92
+ export interface HardwareCheckResult {
93
+ hardware: HardwareInfo;
94
+ recommendedModel: ModelTier;
95
+ warnings: string[];
96
+ }
97
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AACpD,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC;AACnC,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAChD,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,aAAa,CAAC;AAItD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAID,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,SAAS,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAID,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,KAAK,EAAE,SAAS,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAID,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;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E,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAID,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAID,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,CAAC;IACvB,gBAAgB,EAAE,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ // ─────────────────────────────────────────────────────────────────────────────
2
+ // repoDoc Local — Core Types
3
+ // Design: dark brutalist terminal aesthetic (#0A0A0A bg, emerald-400 accents)
4
+ // ─────────────────────────────────────────────────────────────────────────────
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6BAA6B;AAC7B,8EAA8E;AAC9E,gFAAgF"}
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "repodoc-local",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Local-first AI bug fixer and guardrails. Code never leaves your machine. Powered by Gemma 4.",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=18"
8
+ },
9
+ "bin": {
10
+ "repodoc": "dist/cli.js",
11
+ "repodoc-local": "dist/cli.js"
12
+ },
13
+ "main": "dist/cli.js",
14
+ "types": "dist/cli.d.ts",
15
+ "files": [
16
+ "dist",
17
+ "prompts",
18
+ "repodoc.example.yml",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "prepublishOnly": "npm run build",
24
+ "dev": "ts-node src/cli.ts",
25
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest"
26
+ },
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/rusky-lms/repoDoc.git",
31
+ "directory": "packages/repodoc-local"
32
+ },
33
+ "keywords": [
34
+ "local-first",
35
+ "gemma",
36
+ "ollama",
37
+ "code-review",
38
+ "privacy",
39
+ "guardrails"
40
+ ],
41
+ "dependencies": {
42
+ "chalk": "^5.3.0",
43
+ "commander": "^12.1.0",
44
+ "node-fetch": "^3.3.2",
45
+ "ora": "^8.1.1"
46
+ },
47
+ "devDependencies": {
48
+ "@types/jest": "^29.5.14",
49
+ "@types/node": "^22.9.1",
50
+ "jest": "^29.7.0",
51
+ "ts-jest": "^29.2.5",
52
+ "ts-node": "^10.9.2",
53
+ "typescript": "^5.6.3"
54
+ },
55
+ "jest": {
56
+ "preset": "ts-jest/presets/default-esm",
57
+ "testEnvironment": "node",
58
+ "extensionsToTreatAsEsm": [
59
+ ".ts"
60
+ ],
61
+ "moduleNameMapper": {
62
+ "^(\\.{1,2}/.*)\\.js$": "$1"
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,28 @@
1
+ You are a code reviewer. Find at most 2 real bugs in the code below.
2
+
3
+ ## File Map
4
+ {{FILE_MAP}}
5
+
6
+ ## Guardrail Results
7
+ {{GUARDRAIL_RESULTS}}
8
+
9
+ ## Code
10
+ {{CODE}}
11
+
12
+ ---
13
+
14
+ ## Instructions
15
+
16
+ 1. Find the 2 most critical bugs only. Skip style issues or minor nits.
17
+ 2. For each bug:
18
+ - `id` — kebab-case identifier
19
+ - `file` — relative file path
20
+ - `line` — line number or null
21
+ - `description` — ≤ 50 words, what is wrong and why it matters
22
+ - `confidence` — float 0.0–1.0
23
+ - `fix_diff` — minimal unified diff to fix it
24
+ 3. Output ONLY valid JSON. No markdown, no commentary.
25
+
26
+ ## Output Format
27
+
28
+ {"bugs":[{"id":"string","file":"string","line":1,"description":"string","confidence":0.9,"fix_diff":"string"}]}
@@ -0,0 +1,31 @@
1
+ You are a senior software engineer performing a focused code review.
2
+ You will be given a repository file map, guardrail findings, and source code.
3
+ Your task: identify the TOP 3 bugs or issues that have the highest impact.
4
+
5
+ ## Repository File Map
6
+ {{FILE_MAP}}
7
+
8
+ ## Guardrail Results
9
+ {{GUARDRAIL_RESULTS}}
10
+
11
+ ## Source Code
12
+ {{CODE}}
13
+
14
+ ---
15
+
16
+ ## Instructions
17
+
18
+ 1. Analyse the code carefully. Prioritise bugs that cause incorrect behaviour, data loss, security risk, or crashes.
19
+ 2. For each bug, produce:
20
+ - `id` — a short kebab-case identifier (e.g. "null-deref-login")
21
+ - `file` — file path relative to repo root
22
+ - `line` — approximate line number (integer, or null if not applicable)
23
+ - `description` — what the bug is and why it matters (≤ 80 words)
24
+ - `confidence` — float 0.0–1.0 (how certain you are this is a real bug)
25
+ - `fix_diff` — a minimal unified diff that fixes the bug (use --- / +++ / @@ format)
26
+ 3. Output ONLY valid JSON, no markdown fences, no commentary.
27
+ 4. If fewer than 3 genuine bugs exist, return only what you found (do not invent issues).
28
+
29
+ ## Output Format
30
+
31
+ {"bugs":[{"id":"string","file":"string","line":1,"description":"string","confidence":0.9,"fix_diff":"string"}]}
@@ -0,0 +1,27 @@
1
+ # repoDoc Guardrail Configuration
2
+ # Place this file as 'repodoc.yml' in the root of your repository.
3
+
4
+ rules:
5
+ - id: no_console_log
6
+ name: No Console Logs
7
+ category: quality
8
+ type: pattern
9
+ pattern: "console\\.log\\("
10
+ severity: warning
11
+ description: "Detects unremoved console.log statements in production code"
12
+
13
+ - id: no_http_urls
14
+ name: No Insecure HTTP URLs
15
+ category: security
16
+ type: pattern
17
+ pattern: "http://(?!localhost|127\\.0\\.0\\.1)"
18
+ severity: warning
19
+ description: "Detects insecure http:// URLs that should use https://"
20
+
21
+ - id: require_strict_equality
22
+ name: Require Strict Equality
23
+ category: quality
24
+ type: pattern
25
+ pattern: "[^!=]==[^=]"
26
+ severity: info
27
+ description: "Avoid loose equality checks (==) in JavaScript/TypeScript"