coding-agent-skills 0.2.10 → 0.2.11

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 (45) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +4 -0
  3. package/ROADMAP.md +7 -5
  4. package/bin/coding-agent-skills +7 -0
  5. package/docs/adapters/README.md +19 -0
  6. package/docs/adapters/project-installation.md +12 -0
  7. package/docs/adapters/real-project-adoption.md +1 -1
  8. package/docs/architecture/README.md +4 -3
  9. package/docs/release/README.md +3 -2
  10. package/docs/release/npm-package.md +6 -2
  11. package/docs/safety/README.md +6 -1
  12. package/docs/testing/README.md +8 -0
  13. package/docs/usage/README.md +14 -5
  14. package/examples/command-policies/secret-audit.json +71 -0
  15. package/examples/evidence-packs/secret-audit.json +55 -0
  16. package/examples/manifests/secret-audit.json +14 -0
  17. package/examples/workflows/secret-audit.md +10 -0
  18. package/package.json +2 -1
  19. package/runs/skill-runs.md +16 -0
  20. package/schemas/project-adapter-installation.schema.json +2 -0
  21. package/schemas/project-adapter.schema.json +2 -0
  22. package/scripts/lib/pack-rules.mjs +11 -2
  23. package/scripts/lib/secret-audit.mjs +510 -0
  24. package/scripts/render-secret-audit.mjs +8 -0
  25. package/scripts/test-pack.mjs +69 -1
  26. package/scripts/validate-pack.mjs +5 -2
  27. package/skills/secret-audit/SKILL.md +57 -0
  28. package/skills/secret-audit/adapter-interface.md +12 -0
  29. package/skills/secret-audit/agents/openai.yaml +4 -0
  30. package/skills/secret-audit/checklist.md +7 -0
  31. package/skills/secret-audit/evidence-template.md +15 -0
  32. package/skills/secret-audit/examples.md +27 -0
  33. package/skills/secret-audit/failure-modes.md +5 -0
  34. package/tests/fixtures/secret-audit/adapter-project/.coding-agent/adapters/secret-audit-fixture/adapter.json +53 -0
  35. package/tests/fixtures/secret-audit/adapter-project/.coding-agent/skills.json +23 -0
  36. package/tests/fixtures/secret-audit/adapter-project/README.md +3 -0
  37. package/tests/fixtures/secret-audit/adapter-project/package.json +4 -0
  38. package/tests/fixtures/secret-audit/adapter-project/src/placeholder.ts +1 -0
  39. package/tests/fixtures/secret-audit/static-project/.env.example +1 -0
  40. package/tests/fixtures/secret-audit/static-project/README.md +3 -0
  41. package/tests/fixtures/secret-audit/static-project/package.json +4 -0
  42. package/tests/fixtures/secret-audit/static-project/src/config.ts +1 -0
  43. package/tests/fixtures/triggers/cases.json +13 -1
  44. package/tests/trigger/README.md +2 -0
  45. package/work-ledger.md +18 -6
@@ -0,0 +1,510 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ import {
7
+ ADAPTER_MANIFEST_FILENAME,
8
+ readSafeJsonFile,
9
+ } from "./adapter-discovery.mjs";
10
+ import { PILOT_VERSION } from "./pack-rules.mjs";
11
+ import {
12
+ readProjectAdapterDeclaration,
13
+ validateProjectAdapters,
14
+ } from "./project-adapter-installation.mjs";
15
+
16
+ const DEFAULT_CORE_ROOT = path.resolve(
17
+ path.dirname(fileURLToPath(import.meta.url)),
18
+ "..",
19
+ "..",
20
+ );
21
+
22
+ const DEFAULT_IGNORED_PATHS = [
23
+ ".git",
24
+ ".next",
25
+ "node_modules",
26
+ "dist",
27
+ "build",
28
+ "coverage",
29
+ "out",
30
+ "validation-output",
31
+ ];
32
+
33
+ const TEXT_EXTENSIONS = new Set([
34
+ ".cjs",
35
+ ".cts",
36
+ ".js",
37
+ ".jsx",
38
+ ".json",
39
+ ".md",
40
+ ".mjs",
41
+ ".mts",
42
+ ".sql",
43
+ ".ts",
44
+ ".tsx",
45
+ ".txt",
46
+ ".yaml",
47
+ ".yml",
48
+ ]);
49
+
50
+ const REFUSED_BEHAVIOR = [
51
+ "no .env reads",
52
+ "no secret-file reads",
53
+ "no matched value printing",
54
+ "no credential stores",
55
+ "no credential rotation",
56
+ "no API calls",
57
+ "no target project builds",
58
+ "no target project tests",
59
+ "no package installs",
60
+ "no deployments",
61
+ "no migrations",
62
+ "no project writes",
63
+ ];
64
+
65
+ const NOT_VERIFIED = [
66
+ "ignored secret files such as .env",
67
+ "credential stores and local keychains",
68
+ "runtime-injected secrets",
69
+ "remote repository history",
70
+ "cloud provider secret stores",
71
+ "whether a redacted finding is active or revoked",
72
+ ];
73
+
74
+ const SECRET_PATTERNS = [
75
+ {
76
+ type: "private-key",
77
+ pattern:
78
+ /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/g,
79
+ },
80
+ {
81
+ type: "authorization-header",
82
+ pattern: /Authorization:\s*Bearer\s+[A-Za-z0-9._-]{12,}/gi,
83
+ },
84
+ {
85
+ type: "github-token",
86
+ pattern: /\bgh[pousr]_[A-Za-z0-9_]{20,}\b/g,
87
+ },
88
+ {
89
+ type: "github-token",
90
+ pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}\b/gi,
91
+ },
92
+ {
93
+ type: "jwt",
94
+ pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,
95
+ },
96
+ {
97
+ type: "url-credentials",
98
+ pattern: /\b[a-z][a-z0-9+.-]*:\/\/[^/\s:@]+:[^@\s/]+@[^\s]+/gi,
99
+ },
100
+ {
101
+ type: "secret-assignment",
102
+ pattern:
103
+ /(?:^|\n)[A-Z][A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|PRIVATE_KEY|DATABASE_URL|API_KEY)=[^\s"'`]+/g,
104
+ },
105
+ ];
106
+
107
+ function inside(root, candidate) {
108
+ const relative = path.relative(root, candidate);
109
+ return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
110
+ }
111
+
112
+ function toPosix(relativePath) {
113
+ return relativePath.split(path.sep).join("/");
114
+ }
115
+
116
+ function safeRelativePath(candidate) {
117
+ return (
118
+ typeof candidate === "string" &&
119
+ candidate.length > 0 &&
120
+ !candidate.startsWith("/") &&
121
+ !candidate.split(/[\\/]+/).includes("..")
122
+ );
123
+ }
124
+
125
+ function secretBearingPath(relativePath) {
126
+ const normalized = toPosix(relativePath);
127
+ const basename = path.posix.basename(normalized);
128
+ return (
129
+ basename === ".env" ||
130
+ (basename.startsWith(".env.") && basename !== ".env.example") ||
131
+ basename === ".npmrc" ||
132
+ /\.(?:pem|key|p12|pfx)$/i.test(basename) ||
133
+ /(?:^|\/)(?:secrets?|credentials?|private-key)(?:\/|$)/i.test(normalized)
134
+ );
135
+ }
136
+
137
+ function ignoredBy(relativePath, ignoredPaths) {
138
+ const normalized = toPosix(relativePath);
139
+ return ignoredPaths.some((ignored) => {
140
+ const clean = toPosix(ignored).replace(/\/+$/g, "");
141
+ return normalized === clean || normalized.startsWith(`${clean}/`);
142
+ });
143
+ }
144
+
145
+ function gitSummary(projectRoot) {
146
+ const summary = {
147
+ root: null,
148
+ branchState: null,
149
+ hasUncommittedChanges: false,
150
+ warnings: [],
151
+ };
152
+ const revParse = spawnSync("git", ["rev-parse", "--show-toplevel"], {
153
+ cwd: projectRoot,
154
+ encoding: "utf8",
155
+ stdio: ["ignore", "pipe", "pipe"],
156
+ });
157
+ if (revParse.status === 0) summary.root = revParse.stdout.trim();
158
+ const status = spawnSync("git", ["status", "--short", "--branch"], {
159
+ cwd: projectRoot,
160
+ encoding: "utf8",
161
+ stdio: ["ignore", "pipe", "pipe"],
162
+ });
163
+ if (status.status !== 0) {
164
+ summary.warnings.push("git status unavailable");
165
+ return summary;
166
+ }
167
+ const lines = status.stdout.split(/\r?\n/).filter(Boolean);
168
+ summary.branchState = lines[0] ?? null;
169
+ summary.hasUncommittedChanges = lines.length > 1;
170
+ if (summary.hasUncommittedChanges) summary.warnings.push("working tree has local changes; filenames omitted");
171
+ if (/\[(?:ahead|behind|gone|diverged)[^\]]*\]/i.test(summary.branchState ?? "")) {
172
+ summary.warnings.push("branch state indicates remote divergence; revalidate after update");
173
+ }
174
+ return summary;
175
+ }
176
+
177
+ function adapterContext(projectRootInput, coreRoot) {
178
+ const loaded = readProjectAdapterDeclaration(projectRootInput);
179
+ if (!loaded.ok) {
180
+ if (loaded.codes.length === 1 && loaded.codes[0] === "missing-project-declaration") {
181
+ return {
182
+ ok: true,
183
+ present: false,
184
+ enabled: false,
185
+ projectRoot: path.resolve(projectRootInput),
186
+ mode: "none",
187
+ codes: [],
188
+ };
189
+ }
190
+ return { ok: false, present: false, enabled: false, status: "failed", codes: loaded.codes };
191
+ }
192
+
193
+ const validation = validateProjectAdapters(loaded.projectRoot, { coreRoot });
194
+ if (!validation.ok) {
195
+ return {
196
+ ok: false,
197
+ present: true,
198
+ enabled: false,
199
+ status: "failed",
200
+ codes: validation.codes,
201
+ validation,
202
+ };
203
+ }
204
+
205
+ if (!validation.acceptedSkills.includes("secret-audit")) {
206
+ return {
207
+ ok: true,
208
+ present: true,
209
+ enabled: false,
210
+ projectRoot: loaded.projectRoot,
211
+ mode: "adapter-present-secret-audit-not-enabled",
212
+ declarationPath: loaded.declarationPath,
213
+ declaration: loaded.declaration,
214
+ validation,
215
+ codes: ["secret-audit-not-enabled-by-adapter"],
216
+ };
217
+ }
218
+
219
+ const adapters = [];
220
+ const errors = [];
221
+ const container = path.resolve(loaded.projectRoot, loaded.declaration.adapterRoot);
222
+ if (!inside(loaded.projectRoot, container) || !fs.existsSync(container)) {
223
+ errors.push("adapter-root-not-found");
224
+ } else {
225
+ for (const declaration of loaded.declaration.adapters ?? []) {
226
+ if (!(declaration.skillIds ?? []).includes("secret-audit")) continue;
227
+ const manifestPath = path.join(container, declaration.id, ADAPTER_MANIFEST_FILENAME);
228
+ const record = readSafeJsonFile(manifestPath);
229
+ if (!record.value) {
230
+ errors.push(...record.codes);
231
+ continue;
232
+ }
233
+ adapters.push({
234
+ declaration,
235
+ manifestPath: path.relative(loaded.projectRoot, manifestPath),
236
+ manifest: record.value,
237
+ });
238
+ }
239
+ }
240
+ if (errors.length) {
241
+ return { ok: false, present: true, enabled: false, status: "failed", codes: errors, validation };
242
+ }
243
+ return {
244
+ ok: true,
245
+ present: true,
246
+ enabled: true,
247
+ projectRoot: loaded.projectRoot,
248
+ mode: "adapter-enabled",
249
+ declarationPath: loaded.declarationPath,
250
+ declaration: loaded.declaration,
251
+ validation,
252
+ adapters,
253
+ codes: [],
254
+ };
255
+ }
256
+
257
+ function scopeFromAdapter(context) {
258
+ const safeReadPaths = new Set();
259
+ const ignoredPaths = new Set(DEFAULT_IGNORED_PATHS);
260
+ for (const adapter of context.adapters ?? []) {
261
+ for (const candidate of adapter.manifest.extensions?.safeReadPaths ?? []) {
262
+ if (safeRelativePath(candidate)) safeReadPaths.add(candidate);
263
+ }
264
+ for (const candidate of adapter.manifest.extensions?.ignoredPaths ?? []) {
265
+ if (safeRelativePath(candidate)) ignoredPaths.add(candidate);
266
+ }
267
+ }
268
+ return {
269
+ scopePaths: safeReadPaths.size ? [...safeReadPaths].sort() : ["."],
270
+ ignoredPaths: [...ignoredPaths].sort(),
271
+ };
272
+ }
273
+
274
+ function candidateFile(relativePath) {
275
+ const basename = path.posix.basename(toPosix(relativePath));
276
+ if (basename === ".env.example") return true;
277
+ return TEXT_EXTENSIONS.has(path.extname(basename));
278
+ }
279
+
280
+ function collectFiles(projectRoot, scopePaths, ignoredPaths) {
281
+ const files = [];
282
+ const skipped = [];
283
+ for (const scopePath of scopePaths) {
284
+ if (!safeRelativePath(scopePath) && scopePath !== ".") {
285
+ skipped.push({ path: scopePath, reason: "unsafe scope path" });
286
+ continue;
287
+ }
288
+ const absolute = path.resolve(projectRoot, scopePath);
289
+ if (!inside(projectRoot, absolute)) {
290
+ skipped.push({ path: scopePath, reason: "scope escapes project root" });
291
+ continue;
292
+ }
293
+ if (!fs.existsSync(absolute)) {
294
+ skipped.push({ path: scopePath, reason: "scope path not found" });
295
+ continue;
296
+ }
297
+ walkPath(projectRoot, absolute, ignoredPaths, files, skipped);
298
+ }
299
+ return { files: [...new Set(files)].sort(), skipped };
300
+ }
301
+
302
+ function walkPath(projectRoot, absolute, ignoredPaths, files, skipped) {
303
+ const relative = toPosix(path.relative(projectRoot, absolute)) || ".";
304
+ if (relative !== "." && ignoredBy(relative, ignoredPaths)) {
305
+ skipped.push({ path: relative, reason: "ignored path" });
306
+ return;
307
+ }
308
+ if (relative !== "." && secretBearingPath(relative)) {
309
+ skipped.push({ path: relative, reason: "secret-bearing path excluded" });
310
+ return;
311
+ }
312
+ const stat = fs.lstatSync(absolute);
313
+ if (stat.isSymbolicLink()) {
314
+ skipped.push({ path: relative, reason: "symbolic link skipped" });
315
+ return;
316
+ }
317
+ if (stat.isDirectory()) {
318
+ for (const entry of fs.readdirSync(absolute)) {
319
+ walkPath(projectRoot, path.join(absolute, entry), ignoredPaths, files, skipped);
320
+ }
321
+ return;
322
+ }
323
+ if (!stat.isFile()) return;
324
+ if (stat.size > 512_000) {
325
+ skipped.push({ path: relative, reason: "file larger than bounded read limit" });
326
+ return;
327
+ }
328
+ if (!candidateFile(relative)) {
329
+ skipped.push({ path: relative, reason: "not a secret-audit candidate file" });
330
+ return;
331
+ }
332
+ files.push(relative);
333
+ }
334
+
335
+ function scanSecrets(projectRoot, files) {
336
+ const findings = [];
337
+ const warnings = [];
338
+ for (const relative of files) {
339
+ let text = "";
340
+ try {
341
+ text = fs.readFileSync(path.join(projectRoot, relative), "utf8");
342
+ } catch {
343
+ warnings.push(`could not read ${relative}`);
344
+ continue;
345
+ }
346
+ for (const secretPattern of SECRET_PATTERNS) {
347
+ secretPattern.pattern.lastIndex = 0;
348
+ let count = 0;
349
+ for (const _match of text.matchAll(secretPattern.pattern)) count += 1;
350
+ if (count > 0) findings.push({ path: relative, type: secretPattern.type, count });
351
+ }
352
+ }
353
+ return { findings: findings.sort((a, b) => `${a.path}:${a.type}`.localeCompare(`${b.path}:${b.type}`)), warnings };
354
+ }
355
+
356
+ export function buildSecretAuditReport(projectRootInput, options = {}) {
357
+ const coreRoot = options.coreRoot ?? DEFAULT_CORE_ROOT;
358
+ const context = adapterContext(projectRootInput, coreRoot);
359
+ if (!context.ok) {
360
+ return {
361
+ status: "failed",
362
+ coreVersion: PILOT_VERSION,
363
+ projectRoot: path.resolve(projectRootInput ?? "."),
364
+ adapter: context,
365
+ git: gitSummary(path.resolve(projectRootInput ?? ".")),
366
+ scopePaths: [],
367
+ ignoredPaths: DEFAULT_IGNORED_PATHS,
368
+ filesScanned: [],
369
+ findings: [],
370
+ skipped: [],
371
+ warnings: context.codes ?? [],
372
+ notVerified: NOT_VERIFIED,
373
+ refusedBehavior: REFUSED_BEHAVIOR,
374
+ };
375
+ }
376
+
377
+ const projectRoot = context.projectRoot;
378
+ const git = gitSummary(projectRoot);
379
+ if (context.present && !context.enabled) {
380
+ return {
381
+ status: "partial",
382
+ coreVersion: PILOT_VERSION,
383
+ projectRoot,
384
+ adapter: context,
385
+ git,
386
+ scopePaths: [],
387
+ ignoredPaths: DEFAULT_IGNORED_PATHS,
388
+ filesScanned: [],
389
+ findings: [],
390
+ skipped: [{ path: ".", reason: "project adapter is present but does not enable secret-audit" }],
391
+ warnings: [
392
+ "secret-audit is not enabled by the project adapter; target files were not read",
393
+ ...git.warnings,
394
+ ],
395
+ notVerified: NOT_VERIFIED,
396
+ refusedBehavior: REFUSED_BEHAVIOR,
397
+ };
398
+ }
399
+
400
+ const scope = context.enabled
401
+ ? scopeFromAdapter(context)
402
+ : { scopePaths: ["."], ignoredPaths: DEFAULT_IGNORED_PATHS };
403
+ const collected = collectFiles(projectRoot, scope.scopePaths, scope.ignoredPaths);
404
+ const scanned = scanSecrets(projectRoot, collected.files);
405
+ return {
406
+ status: "complete",
407
+ coreVersion: PILOT_VERSION,
408
+ projectRoot,
409
+ adapter: context,
410
+ git,
411
+ scopePaths: scope.scopePaths,
412
+ ignoredPaths: scope.ignoredPaths,
413
+ filesScanned: collected.files,
414
+ findings: scanned.findings,
415
+ skipped: collected.skipped,
416
+ warnings: [
417
+ ...git.warnings,
418
+ ...scanned.warnings,
419
+ ...(context.enabled ? ["secret-audit used adapter-declared safe read paths only"] : []),
420
+ ...(context.present ? [] : ["no project adapter declaration found; secret-audit used generic bounded static scan"]),
421
+ ],
422
+ notVerified: NOT_VERIFIED,
423
+ refusedBehavior: REFUSED_BEHAVIOR,
424
+ };
425
+ }
426
+
427
+ export function renderSecretAuditReport(report) {
428
+ const totalFindings = report.findings.reduce((sum, finding) => sum + finding.count, 0);
429
+ const lines = [
430
+ "# Secret Audit Report",
431
+ "",
432
+ `Status: ${report.status}`,
433
+ `Core version: ${report.coreVersion}`,
434
+ `Project root: ${report.projectRoot}`,
435
+ "",
436
+ "## Git State",
437
+ `- Git root: ${report.git.root ?? "not detected"}`,
438
+ `- Branch state: ${report.git.branchState ?? "not detected"}`,
439
+ `- Local changes: ${report.git.hasUncommittedChanges ? "detected" : "not detected"}`,
440
+ "",
441
+ "## Adapter Scope",
442
+ `- Adapter present: ${report.adapter.present ? "yes" : "no"}`,
443
+ `- Secret-audit enabled: ${report.adapter.enabled ? "yes" : "no"}`,
444
+ `- Mode: ${report.adapter.mode}`,
445
+ "",
446
+ "## Scope Paths",
447
+ ...(report.scopePaths.length ? report.scopePaths.map((item) => `- ${item}`) : ["- none"]),
448
+ "",
449
+ "## Ignored Paths",
450
+ ...report.ignoredPaths.map((item) => `- ${item}`),
451
+ "",
452
+ "## Summary",
453
+ `- Static files scanned: ${report.filesScanned.length}`,
454
+ `- Secret-like findings: ${totalFindings}`,
455
+ `- Files with findings: ${new Set(report.findings.map((finding) => finding.path)).size}`,
456
+ `- Skipped items: ${report.skipped.length}`,
457
+ "",
458
+ "## Findings",
459
+ ];
460
+ if (report.findings.length) {
461
+ for (const finding of report.findings) {
462
+ lines.push(`- ${finding.path}: ${finding.count} ${finding.type} match(es); values omitted`);
463
+ }
464
+ } else {
465
+ lines.push("- none found");
466
+ }
467
+
468
+ lines.push("", "## Skipped");
469
+ if (report.skipped.length) {
470
+ for (const skipped of report.skipped.slice(0, 40)) {
471
+ lines.push(`- ${skipped.path}: ${skipped.reason}`);
472
+ }
473
+ if (report.skipped.length > 40) lines.push(`- ${report.skipped.length - 40} additional skipped items omitted`);
474
+ } else {
475
+ lines.push("- none");
476
+ }
477
+
478
+ lines.push("", "## Not Verified");
479
+ for (const item of report.notVerified) lines.push(`- ${item}`);
480
+ lines.push("", "## Warnings");
481
+ if (report.warnings.length) {
482
+ for (const warning of report.warnings) lines.push(`- ${warning}`);
483
+ } else {
484
+ lines.push("- none");
485
+ }
486
+ lines.push("", "## Refused Behavior");
487
+ for (const item of report.refusedBehavior) lines.push(`- ${item}`);
488
+ lines.push(
489
+ "",
490
+ "No .env, secret-file, credential-store, API, build, test, deploy, migration, package-install, value-printing, rotation, or project-write behavior was performed.",
491
+ );
492
+ return lines.join("\n");
493
+ }
494
+
495
+ export function secretAuditCliResult(projectRootInput, options = {}) {
496
+ if (!projectRootInput) {
497
+ return {
498
+ exitCode: 2,
499
+ stream: "stderr",
500
+ lines: ["usage: node scripts/render-secret-audit.mjs <project-root>"],
501
+ };
502
+ }
503
+ const report = buildSecretAuditReport(projectRootInput, options);
504
+ return {
505
+ exitCode: report.status === "failed" ? 1 : 0,
506
+ stream: report.status === "failed" ? "stderr" : "stdout",
507
+ lines: renderSecretAuditReport(report).split("\n"),
508
+ report,
509
+ };
510
+ }
@@ -0,0 +1,8 @@
1
+ import { secretAuditCliResult } from "./lib/secret-audit.mjs";
2
+
3
+ const outcome = secretAuditCliResult(process.argv[2]);
4
+ for (const line of outcome.lines) {
5
+ if (outcome.stream === "stdout") console.log(line);
6
+ else console.error(line);
7
+ }
8
+ process.exitCode = outcome.exitCode;
@@ -52,6 +52,11 @@ import {
52
52
  envAuditCliResult,
53
53
  renderEnvAuditReport,
54
54
  } from "./lib/env-audit.mjs";
55
+ import {
56
+ buildSecretAuditReport,
57
+ renderSecretAuditReport,
58
+ secretAuditCliResult,
59
+ } from "./lib/secret-audit.mjs";
55
60
  import {
56
61
  adapterUpgradeCliResult,
57
62
  checkAdapterUpgrade,
@@ -268,6 +273,7 @@ test("local CLI maps approved commands to existing safe scripts", () => {
268
273
  assert.ok(cliText.includes("scripts/render-adapter-repo-map.mjs"));
269
274
  assert.ok(cliText.includes("scripts/render-route-trace.mjs"));
270
275
  assert.ok(cliText.includes("scripts/render-env-audit.mjs"));
276
+ assert.ok(cliText.includes("scripts/render-secret-audit.mjs"));
271
277
  assert.ok(cliText.includes("scripts/validate-adapters.mjs"));
272
278
  assert.ok(!cliText.includes(".env"));
273
279
 
@@ -297,6 +303,10 @@ test("local CLI maps approved commands to existing safe scripts", () => {
297
303
  ["env-audit", path.join(fixtureRoot, "env-audit", "static-project")],
298
304
  /# Env Audit Report/,
299
305
  ],
306
+ [
307
+ ["secret-audit", path.join(fixtureRoot, "secret-audit", "static-project")],
308
+ /# Secret Audit Report/,
309
+ ],
300
310
  ];
301
311
 
302
312
  for (const [args, expected] of commands) {
@@ -321,7 +331,7 @@ test("local CLI maps approved commands to existing safe scripts", () => {
321
331
  test("npm package metadata is public-ready and dependency-free", () => {
322
332
  const packageJson = readJson("package.json");
323
333
  assert.equal(packageJson.name, "coding-agent-skills");
324
- assert.equal(packageJson.version, "0.2.10");
334
+ assert.equal(packageJson.version, "0.2.11");
325
335
  assert.equal(
326
336
  packageJson.description,
327
337
  "Evidence-first, read-only coding-agent skills and project adapter tooling.",
@@ -335,6 +345,7 @@ test("npm package metadata is public-ready and dependency-free", () => {
335
345
  "repo-map",
336
346
  "route-trace",
337
347
  "env-audit",
348
+ "secret-audit",
338
349
  "project-adapters",
339
350
  "code-validation",
340
351
  "cli",
@@ -521,6 +532,63 @@ test("env-audit does not broaden a repo-map-only project adapter", () => {
521
532
  assert.match(renderEnvAuditReport(result), /env-audit is not enabled/);
522
533
  });
523
534
 
535
+ test("secret-audit reports high-confidence findings without printing values", () => {
536
+ const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "secret-audit-fixture-"));
537
+ fs.cpSync(path.join(root, "tests", "fixtures", "secret-audit", "static-project"), temporary, {
538
+ recursive: true,
539
+ });
540
+ const syntheticSecret = ["github", "_pat_", "A".repeat(24)].join("");
541
+ fs.writeFileSync(
542
+ path.join(temporary, "src", "leak.ts"),
543
+ `export const candidate = "${syntheticSecret}";\n`,
544
+ );
545
+ fs.writeFileSync(path.join(temporary, ".env"), `DO_NOT_READ=${syntheticSecret}\n`);
546
+
547
+ const result = buildSecretAuditReport(temporary, { coreRoot: root });
548
+ const rendered = renderSecretAuditReport(result);
549
+
550
+ assert.equal(result.status, "complete");
551
+ assert.ok(result.filesScanned.includes("src/leak.ts"));
552
+ assert.ok(!result.filesScanned.includes(".env"));
553
+ assert.ok(result.skipped.some((item) => item.path === ".env"));
554
+ assert.ok(result.findings.some((finding) => finding.path === "src/leak.ts"));
555
+ assert.ok(result.findings.some((finding) => finding.type === "github-token"));
556
+ assert.match(rendered, /src\/leak\.ts/);
557
+ assert.match(rendered, /values omitted/);
558
+ assert.doesNotMatch(rendered, new RegExp(syntheticSecret));
559
+ });
560
+
561
+ test("secret-audit respects adapter-declared scope", () => {
562
+ const result = buildSecretAuditReport(
563
+ path.join(root, "tests", "fixtures", "secret-audit", "adapter-project"),
564
+ { coreRoot: root },
565
+ );
566
+
567
+ assert.equal(result.status, "complete");
568
+ assert.equal(result.adapter.enabled, true);
569
+ assert.deepEqual(result.scopePaths, ["src"]);
570
+ assert.deepEqual(result.filesScanned, ["src/placeholder.ts"]);
571
+ assert.ok(result.warnings.includes("secret-audit used adapter-declared safe read paths only"));
572
+ const cli = secretAuditCliResult(
573
+ path.join(root, "tests", "fixtures", "secret-audit", "adapter-project"),
574
+ { coreRoot: root },
575
+ );
576
+ assert.equal(cli.exitCode, 0);
577
+ assert.match(cli.lines.join("\n"), /Secret-audit enabled: yes/);
578
+ });
579
+
580
+ test("secret-audit does not broaden a repo-map-only project adapter", () => {
581
+ const result = buildSecretAuditReport(
582
+ path.join(root, "tests", "fixtures", "project-adapter-installation", "valid-exact-pin"),
583
+ { coreRoot: root },
584
+ );
585
+
586
+ assert.equal(result.status, "partial");
587
+ assert.equal(result.filesScanned.length, 0);
588
+ assert.equal(result.findings.length, 0);
589
+ assert.match(renderSecretAuditReport(result), /secret-audit is not enabled/);
590
+ });
591
+
524
592
  test("validate-pack accepts installed package trees without source-only gitignore", () => {
525
593
  const temporaryRoot = fs.mkdtempSync(path.join(os.tmpdir(), "installed-package-"));
526
594
  const installedRoot = path.join(temporaryRoot, "coding-agent-skills");
@@ -97,6 +97,7 @@ const requiredRootFiles = [
97
97
  "scripts/render-adapter-repo-map.mjs",
98
98
  "scripts/render-route-trace.mjs",
99
99
  "scripts/render-env-audit.mjs",
100
+ "scripts/render-secret-audit.mjs",
100
101
  "scripts/check-adapter-upgrade.mjs",
101
102
  "scripts/check-adapter-upgrade-chain.mjs",
102
103
  "scripts/validate-adapters.mjs",
@@ -104,6 +105,7 @@ const requiredRootFiles = [
104
105
  "scripts/lib/adapter-repo-map.mjs",
105
106
  "scripts/lib/route-trace.mjs",
106
107
  "scripts/lib/env-audit.mjs",
108
+ "scripts/lib/secret-audit.mjs",
107
109
  "scripts/lib/adapter-upgrade.mjs",
108
110
  "scripts/lib/adapter-upgrade-chain.mjs",
109
111
  "scripts/lib/adapter-discovery.mjs",
@@ -677,8 +679,8 @@ if (packageJson) {
677
679
  if (packageJson.name !== "coding-agent-skills") {
678
680
  failures.push("package.json has unexpected package name");
679
681
  }
680
- if (packageJson.version !== "0.2.10") {
681
- failures.push("package.json version must be 0.2.10 for public package validation");
682
+ if (packageJson.version !== "0.2.11") {
683
+ failures.push("package.json version must be 0.2.11 for public package validation");
682
684
  }
683
685
  if (packageJson.type !== "module") failures.push("package.json must preserve ESM mode");
684
686
  if (packageJson.private !== false) {
@@ -698,6 +700,7 @@ if (packageJson) {
698
700
  "repo-map",
699
701
  "route-trace",
700
702
  "env-audit",
703
+ "secret-audit",
701
704
  "project-adapters",
702
705
  "code-validation",
703
706
  "cli",