@xynogen/pix-skills 0.7.12 → 0.7.14
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/package.json +1 -1
- package/skills/harden.md +66 -0
- package/src/index.ts +17 -16
package/package.json
CHANGED
package/skills/harden.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: harden
|
|
3
|
+
description: Retrofit static analysis onto an existing project in any language — lint, format, type/compile check, tests, dependency hygiene, audit, CI gate. Use only on explicit request — "harden this project", "add static analysis", "set up quality gates".
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
# Project Hardening Directive
|
|
7
|
+
|
|
8
|
+
## Goal
|
|
9
|
+
|
|
10
|
+
An existing project gains a fail-fast static-analysis gate: one command locally, same command in CI, red blocks merge. Do not scaffold new projects — that is `bootstrap`'s job.
|
|
11
|
+
|
|
12
|
+
## Phase 1: Audit (read-only)
|
|
13
|
+
|
|
14
|
+
Inventory before touching anything:
|
|
15
|
+
|
|
16
|
+
- **Ecosystem** — detect language(s), build system, package/dependency manager, existing configs (linter, formatter, compiler/type-checker settings, CI files, hooks). Mixed-language repos: audit each language separately.
|
|
17
|
+
- **Existing tools win** — a project with a working linter keeps it; never swap tools for taste. Only fill gaps.
|
|
18
|
+
- **Verify, don't recall** — before proposing any tool, confirm it exists and its flags via `--help` or official docs. Ecosystems move; memory rots.
|
|
19
|
+
- **Gaps checklist** (rank by value/effort, report before applying):
|
|
20
|
+
1. Formatter + linter present and enforced (not just installed)?
|
|
21
|
+
2. Warnings fail CI, or are they decorative?
|
|
22
|
+
3. Strictest static check the language offers covers ALL source including tests — type-check for typed languages, compiler warnings-as-errors, or a type-annotation checker for dynamic ones (mypy/pyright, sorbet, phpstan)?
|
|
23
|
+
4. Test runner wired with at least one real test? Coverage threshold?
|
|
24
|
+
5. Dependency vulnerability audit at high severity (`npm audit`, `cargo audit`, `pip-audit`, `govulncheck`, `mvn dependency-check`, `bundler-audit` — whatever the ecosystem ships)?
|
|
25
|
+
6. Dependency versions locked (lockfile, pinned requirements, go.sum, Cargo.lock) + CI installs exactly those versions (frozen/locked/ci mode)?
|
|
26
|
+
7. CI exists, runs the same commands as local, pinned toolchain version (never `latest`)?
|
|
27
|
+
8. Dead-code / unused-dep detection — only for multi-package repos; use the ecosystem's tool if one exists, skip otherwise.
|
|
28
|
+
|
|
29
|
+
## Phase 2: Propose
|
|
30
|
+
|
|
31
|
+
Present the gap list with one-line fixes and effort estimates. Get approval before installing anything. Skip items the user rejects — no silent extras.
|
|
32
|
+
|
|
33
|
+
## Phase 3: Apply
|
|
34
|
+
|
|
35
|
+
- **One tool per job.** Prefer the ecosystem's converged default (examples: Biome or ESLint+Prettier; ruff+mypy; gofmt+vet+staticcheck; clippy+rustfmt; ktlint+detekt; php-cs-fixer+phpstan). Unsure what the current default is → check docs, don't guess.
|
|
36
|
+
- **Single gate command** — one entry point chaining format-check → lint → static/type check → tests, fail-fast. Use whatever the project already uses to run tasks: package-manager script, Makefile, justfile, rakefile, cargo alias, gradle task. CI calls this exact entry point, never a diverging copy.
|
|
37
|
+
- **Warnings are errors in CI.** A rule worth having is worth failing on.
|
|
38
|
+
- **Coverage: ratchet, don't aspire.** Set threshold to the current actual percentage; raise it later. Never set an aspirational number that fails on day one.
|
|
39
|
+
- **Pin versions** — tool versions locked by the dependency manager (or a pinned tool-version file: `.tool-versions`, `rust-toolchain.toml`, `.python-version`), toolchain version pinned in CI config.
|
|
40
|
+
- Config over code: use the tool's recommended preset + minimal overrides. No 300-line rule files.
|
|
41
|
+
|
|
42
|
+
## Phase 4: Verify + Report
|
|
43
|
+
|
|
44
|
+
- Run the full gate once — must pass green on the untouched codebase (fix or downgrade rules until it does; a gate that starts red gets deleted by the next dev).
|
|
45
|
+
- Break one thing on purpose (introduce a lint error), confirm the gate catches it, revert.
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
## Hardened: [project name]
|
|
49
|
+
|
|
50
|
+
**Gate:** `[command]` → PASS
|
|
51
|
+
**Added:** [tool: purpose, one line each]
|
|
52
|
+
**Skipped:** [item: reason]
|
|
53
|
+
**CI:** [file, trigger, runtime pin]
|
|
54
|
+
**Ratchets:** coverage at N% — raise when it grows
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Mixed-language repo: repeat the gate per language, one top-level command runs all.
|
|
58
|
+
|
|
59
|
+
## Red Flags — STOP
|
|
60
|
+
|
|
61
|
+
- Replacing a working tool the project already uses.
|
|
62
|
+
- Installing anything before Phase 2 approval.
|
|
63
|
+
- A gate that is red on the first run after setup.
|
|
64
|
+
- CI commands that differ from the local gate script.
|
|
65
|
+
- Aspirational coverage thresholds.
|
|
66
|
+
- Adding hooks (husky etc.) when a gate script + CI already covers it — hooks are opt-in, ask first.
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { fileURLToPath } from "node:url";
|
|
|
19
19
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
20
20
|
import { Text } from "@earendil-works/pi-tui";
|
|
21
21
|
import {
|
|
22
|
+
dotJoin,
|
|
22
23
|
formatCollapsedToolRow,
|
|
23
24
|
hideCollapsedToolCall,
|
|
24
25
|
humanSize,
|
|
@@ -292,7 +293,7 @@ export type ThemeLike = {
|
|
|
292
293
|
};
|
|
293
294
|
|
|
294
295
|
export function formatSkillList(names: string[]): string {
|
|
295
|
-
return `Available skills (${names.length}): ${names
|
|
296
|
+
return `Available skills (${names.length}): ${dotJoin(names)}`;
|
|
296
297
|
}
|
|
297
298
|
|
|
298
299
|
function formatInstalls(installs: number): string {
|
|
@@ -308,7 +309,7 @@ export function formatRemoteSkillSearch(query: string, results: RemoteSkillSearc
|
|
|
308
309
|
`skills.sh matches for "${query}" (${results.length}, installs descending):`,
|
|
309
310
|
...ranked.map(
|
|
310
311
|
(result, index) =>
|
|
311
|
-
`${index + 1}. ${result.name
|
|
312
|
+
`${index + 1}. ${dotJoin([result.name, result.source, `${formatInstalls(result.installs)} installs`])}`,
|
|
312
313
|
),
|
|
313
314
|
].join("\n");
|
|
314
315
|
}
|
|
@@ -332,15 +333,15 @@ export type SkillResultDetails =
|
|
|
332
333
|
| { mode: "copy"; name: string; resource: string; output: string; bytes: number };
|
|
333
334
|
|
|
334
335
|
export function formatSkillCallLabel(args: SkillCallArgs): string {
|
|
335
|
-
if (args.search) return
|
|
336
|
-
if (args.source && args.name) return
|
|
336
|
+
if (args.search) return dotJoin(["search", args.search]);
|
|
337
|
+
if (args.source && args.name) return dotJoin(["remote", `${args.source}@${args.name}`]);
|
|
337
338
|
if (!args.name) return "list";
|
|
338
339
|
if (args.resource && args.output) {
|
|
339
|
-
return
|
|
340
|
+
return dotJoin(["copy", `${args.name}/${args.resource} → ${args.output}`]);
|
|
340
341
|
}
|
|
341
|
-
if (args.resource) return
|
|
342
|
-
if (args.full) return
|
|
343
|
-
return
|
|
342
|
+
if (args.resource) return dotJoin(["reference", `${args.name}/${args.resource}`]);
|
|
343
|
+
if (args.full) return dotJoin(["instructions", args.name]);
|
|
344
|
+
return dotJoin(["description", args.name]);
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
export function formatCollapsedSkillResult(details: SkillResultDetails): string {
|
|
@@ -350,13 +351,13 @@ export function formatCollapsedSkillResult(details: SkillResultDetails): string
|
|
|
350
351
|
case "search":
|
|
351
352
|
return `${details.count} matches for “${details.query}”`;
|
|
352
353
|
case "description":
|
|
353
|
-
return
|
|
354
|
+
return dotJoin([details.name, "description"]);
|
|
354
355
|
case "instructions":
|
|
355
|
-
return
|
|
356
|
+
return dotJoin([details.name, `${details.lines} instruction lines`]);
|
|
356
357
|
case "reference":
|
|
357
|
-
return
|
|
358
|
+
return dotJoin([details.name, "reference", humanSize(details.bytes)]);
|
|
358
359
|
case "copy":
|
|
359
|
-
return
|
|
360
|
+
return dotJoin(["copied", details.output, humanSize(details.bytes)]);
|
|
360
361
|
}
|
|
361
362
|
}
|
|
362
363
|
|
|
@@ -389,16 +390,16 @@ export function formatExpandedSkillResult(details: SkillResultDetails, text: str
|
|
|
389
390
|
case "description": {
|
|
390
391
|
const prefix = `${details.name}:`;
|
|
391
392
|
const description = text.startsWith(prefix) ? text.slice(prefix.length).trimStart() : text;
|
|
392
|
-
return
|
|
393
|
+
return `${dotJoin(["DESCRIPTION", details.name])}\n${description}`;
|
|
393
394
|
}
|
|
394
395
|
case "instructions": {
|
|
395
396
|
const preview = text.length > 100 ? `${text.slice(0, 100)}...` : text;
|
|
396
|
-
return
|
|
397
|
+
return `${dotJoin(["INSTRUCTIONS", details.name, `${details.lines} lines`])}\n${preview}`;
|
|
397
398
|
}
|
|
398
399
|
case "reference":
|
|
399
|
-
return
|
|
400
|
+
return `${dotJoin(["REFERENCE", details.name])}\n${dotJoin([details.resource, humanSize(details.bytes)])}\n${text}`;
|
|
400
401
|
case "copy":
|
|
401
|
-
return
|
|
402
|
+
return `${dotJoin(["COPIED", details.name])}\n${dotJoin([`${details.resource} → ${details.output}`, humanSize(details.bytes)])}`;
|
|
402
403
|
}
|
|
403
404
|
}
|
|
404
405
|
|