@srobroek/pi-code-challenge 0.0.0-stage → 2.0.3
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/CHANGELOG.md +80 -0
- package/LICENSE +202 -0
- package/README.md +73 -2
- package/agents/code-challenger.md +64 -0
- package/agents/refactor-challenger.md +81 -0
- package/extensions/index.js +3862 -0
- package/formulas/code-challenge.formula.toml +102 -0
- package/formulas/mol-challenge-challenge.formula.toml +66 -0
- package/formulas/mol-challenge-decide.formula.toml +58 -0
- package/formulas/mol-challenge-deliver.formula.toml +70 -0
- package/formulas/mol-challenge-intake.formula.toml +68 -0
- package/formulas/mol-challenge-lens.formula.toml +59 -0
- package/formulas/mol-challenge-refute.formula.toml +77 -0
- package/formulas/mol-challenge-research.formula.toml +61 -0
- package/formulas/mol-challenge-scan.formula.toml +61 -0
- package/package.json +38 -4
- package/skills/code-challenge/SKILL.md +83 -0
- package/skills/code-challenge/references/decide.md +31 -0
- package/skills/code-challenge/references/decisions.schema.json +21 -0
- package/skills/code-challenge/references/evidence.md +17 -0
- package/skills/code-challenge/references/intake-questions.md +49 -0
- package/skills/code-challenge/references/lens-dead-code.md +20 -0
- package/skills/code-challenge/references/lens-efficiency.md +21 -0
- package/skills/code-challenge/references/lens-hand-rolled-library.md +18 -0
- package/skills/code-challenge/references/lens-hand-rolled-stdlib.md +20 -0
- package/skills/code-challenge/references/lens-observability.md +20 -0
- package/skills/code-challenge/references/lens-optimisation.md +20 -0
- package/skills/code-challenge/references/lens-over-engineering.md +21 -0
- package/skills/code-challenge/references/lens-performance.md +18 -0
- package/skills/code-challenge/references/lens-scope.md +31 -0
- package/skills/code-challenge/references/lens-simplification.md +23 -0
- package/skills/code-challenge/references/lens-stability.md +21 -0
- package/skills/code-challenge/references/lens-structure.md +26 -0
- package/skills/code-challenge/references/lens-tests.md +20 -0
- package/skills/code-challenge/references/library-scoring.md +54 -0
- package/skills/code-challenge/references/report.schema.json +125 -0
- package/skills/code-challenge/references/run-storage.md +22 -0
- package/skills/code-challenge/references/scan.md +36 -0
- package/skills/code-challenge/references/schemas.md +37 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/srobroek/harness-plugins/plugins/code-challenge/report.schema.json",
|
|
4
|
+
"title": "code-challenge report",
|
|
5
|
+
"description": "report.json written by the DELIVER phase.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["run_id", "target", "depth", "mode", "created", "lenses", "summary", "findings", "gaps"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"run_id": { "type": "string", "pattern": "^[0-9]{8}-[0-9]{6}-[a-z0-9-]{1,24}$" },
|
|
11
|
+
"target": { "type": "string", "minLength": 1 },
|
|
12
|
+
"depth": { "enum": ["quick", "standard", "deep"] },
|
|
13
|
+
"mode": { "enum": ["interactive", "autonomous"] },
|
|
14
|
+
"created": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
|
|
15
|
+
"lenses": { "type": "array", "items": { "$ref": "#/$defs/lens" }, "minItems": 1 },
|
|
16
|
+
"summary": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"required": ["found", "accepted", "deferred", "rejected", "dropped"],
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"properties": {
|
|
21
|
+
"found": { "type": "integer", "minimum": 0 },
|
|
22
|
+
"accepted": { "type": "integer", "minimum": 0 },
|
|
23
|
+
"deferred": { "type": "integer", "minimum": 0 },
|
|
24
|
+
"rejected": { "type": "integer", "minimum": 0 },
|
|
25
|
+
"dropped": { "type": "integer", "minimum": 0 }
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"findings": { "type": "array", "items": { "$ref": "#/$defs/finding" } },
|
|
29
|
+
"beads": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"required": ["epic", "children"],
|
|
32
|
+
"additionalProperties": false,
|
|
33
|
+
"properties": {
|
|
34
|
+
"epic": { "type": "string", "minLength": 1 },
|
|
35
|
+
"children": { "type": "array", "items": { "type": "string", "minLength": 1 } }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"comment_draft": { "type": "string" },
|
|
39
|
+
"gaps": { "type": "array", "items": { "type": "string", "minLength": 1 } }
|
|
40
|
+
},
|
|
41
|
+
"$defs": {
|
|
42
|
+
"lens": {
|
|
43
|
+
"enum": [
|
|
44
|
+
"scope",
|
|
45
|
+
"simplification",
|
|
46
|
+
"over-engineering",
|
|
47
|
+
"optimisation",
|
|
48
|
+
"performance",
|
|
49
|
+
"efficiency",
|
|
50
|
+
"stability",
|
|
51
|
+
"hand-rolled-stdlib",
|
|
52
|
+
"hand-rolled-library",
|
|
53
|
+
"dead-code",
|
|
54
|
+
"observability",
|
|
55
|
+
"structure",
|
|
56
|
+
"tests"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"evidence": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"required": ["tier", "detail"],
|
|
62
|
+
"additionalProperties": false,
|
|
63
|
+
"properties": {
|
|
64
|
+
"tier": { "enum": ["proven", "measured", "hypothesis"] },
|
|
65
|
+
"detail": { "type": "string", "minLength": 1 },
|
|
66
|
+
"command": { "type": "string" }
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"location": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"required": ["path", "line"],
|
|
72
|
+
"additionalProperties": false,
|
|
73
|
+
"properties": {
|
|
74
|
+
"path": { "type": "string", "minLength": 1 },
|
|
75
|
+
"line": { "type": "integer", "minimum": 1 }
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"finding": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"required": ["id", "lens", "title", "location", "claim", "evidence", "impact", "blast_radius", "test_protection", "status"],
|
|
81
|
+
"additionalProperties": false,
|
|
82
|
+
"properties": {
|
|
83
|
+
"id": { "type": "string", "pattern": "^F[0-9]+$" },
|
|
84
|
+
"lens": { "$ref": "#/$defs/lens" },
|
|
85
|
+
"title": { "type": "string", "minLength": 1 },
|
|
86
|
+
"location": { "$ref": "#/$defs/location" },
|
|
87
|
+
"recurs": { "type": "integer", "minimum": 1 },
|
|
88
|
+
"also_at": { "type": "array", "items": { "$ref": "#/$defs/location" } },
|
|
89
|
+
"claim": { "type": "string", "minLength": 1 },
|
|
90
|
+
"evidence": { "$ref": "#/$defs/evidence" },
|
|
91
|
+
"impact": { "enum": ["high", "medium", "low"] },
|
|
92
|
+
"blast_radius": { "enum": ["low", "medium", "high"] },
|
|
93
|
+
"changes_contract": { "type": "boolean" },
|
|
94
|
+
"test_protection": { "enum": ["protected", "partial", "unprotected", "not-applicable"] },
|
|
95
|
+
"proposal": { "type": "string" },
|
|
96
|
+
"candidates": {
|
|
97
|
+
"type": "array",
|
|
98
|
+
"items": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"required": ["name", "score", "gates_passed"],
|
|
101
|
+
"additionalProperties": false,
|
|
102
|
+
"properties": {
|
|
103
|
+
"name": { "type": "string", "minLength": 1 },
|
|
104
|
+
"score": { "type": "number", "minimum": 0 },
|
|
105
|
+
"gates_passed": { "type": "boolean" },
|
|
106
|
+
"note": { "type": "string" }
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"refute": {
|
|
111
|
+
"type": "object",
|
|
112
|
+
"required": ["verdict", "rationale"],
|
|
113
|
+
"additionalProperties": false,
|
|
114
|
+
"properties": {
|
|
115
|
+
"verdict": { "enum": ["KEEP", "DOWNGRADE", "DROP"] },
|
|
116
|
+
"rationale": { "type": "string", "minLength": 1 }
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"status": { "enum": ["accepted", "deferred", "rejected", "dropped"] },
|
|
120
|
+
"decided_by": { "enum": ["user", "autonomous-rule"] },
|
|
121
|
+
"bead": { "type": "string" }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Run storage
|
|
2
|
+
|
|
3
|
+
Every run writes to `<git-dir>/code-challenge/<run-id>/`, so nothing lands in the working tree and `git status` stays clean. Resolve the directory with `git rev-parse --git-dir` (in a linked worktree this is the worktree's own git directory). Create it with `mkdir -p`.
|
|
4
|
+
|
|
5
|
+
`<run-id>` is `YYYYMMDD-HHMMSS-<slug>`, the UTC start time plus a slug of the target (lowercase, `-` separated, at most 24 characters). Reuse the id to resume: a phase whose file exists is complete, so skip it unless the user asks to redo it.
|
|
6
|
+
|
|
7
|
+
| File | Written by | Content |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `intake.json` | INTAKE | the answers from [intake-questions.md](intake-questions.md) |
|
|
10
|
+
| `scan.json` | SCAN | analyzer hits, each with tool, rule, `path:line`, and `rule_enabled_in_repo` |
|
|
11
|
+
| `findings.json` | CHALLENGE | one finding per root cause, schema in [schemas.md](schemas.md) |
|
|
12
|
+
| `research.json` | RESEARCH | candidate libraries with scores and gate results |
|
|
13
|
+
| `verdicts.json` | REFUTE | KEEP, DOWNGRADE or DROP per finding, with the rationale and the critic's `tier`, `blast_radius` and `changes_contract` |
|
|
14
|
+
| `decisions.jsonl` | every phase | append-only log, one JSON object per line |
|
|
15
|
+
| `report.json` | DELIVER | the final report, validated by `report.schema.json` |
|
|
16
|
+
| `report.md` | DELIVER | the same report as the chat message |
|
|
17
|
+
|
|
18
|
+
Rules:
|
|
19
|
+
- Append to `decisions.jsonl`, never rewrite it.
|
|
20
|
+
- Write each phase file once, at the end of the phase, before the next phase starts.
|
|
21
|
+
- Never commit the directory. Quote its path in the report so the user can open it.
|
|
22
|
+
- Delete nothing. The user prunes old runs.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# SCAN
|
|
2
|
+
|
|
3
|
+
Phase SCAN uses analyzers the repository can already run, with an isolated lens profile that does not edit repo config and respects its suppressions. No custom rules and no sandbox. A hit from a rule the repository does not enable is tagged "rule not enabled in repo".
|
|
4
|
+
|
|
5
|
+
Run analyzers through `challenge_scan`. It plans per language, lens and depth, runs each recipe and returns normalised candidates plus a coverage list. Write the result to `scan.json`.
|
|
6
|
+
|
|
7
|
+
Input (all optional):
|
|
8
|
+
- `root`: target root; default the session directory.
|
|
9
|
+
- `files`: files, directories or globs inside the root to scope the scan.
|
|
10
|
+
- `languages`: `ts`, `python`, `go`, `rust`; auto-detected by default.
|
|
11
|
+
- `lenses`: lenses to keep; all by default.
|
|
12
|
+
- `depth`: `quick`, `standard` (default) or `deep`.
|
|
13
|
+
- `timeoutSeconds`: per analyzer, default 120, at most 900.
|
|
14
|
+
- `runId`: raw tool output goes to `<git-dir>/code-challenge/<runId>/scan/`.
|
|
15
|
+
- `allowCode`: also run recipes that execute repository or downloaded code. Off by default.
|
|
16
|
+
|
|
17
|
+
Output (JSON text): `root`, `languages`, `depth`, `candidates`, `candidateCount`, `truncated` (inline list capped at 500), `coverage`, `timings` and `rawDir`. A candidate is `{lens, tool, rule, file, line, message, ruleEnabledInRepo}`. `file` and `line` are `null` when the tool gave none (for example an import-linter module with no file). `ruleEnabledInRepo` is `true` or `false` where the scan could tell (ruff, golangci-lint) and `null` otherwise. A coverage entry is `{recipe, tool, language, status, reason?}` with status `ran`, `skipped` or `gap`.
|
|
18
|
+
|
|
19
|
+
Code-running recipes: clippy, golangci-lint, deadcode, knip, import-linter and every one-off `bunx`, `uvx` or `go run` execute repository or downloaded code. Without `allowCode` the scan skips them and lists each as a gap, "not run without allowCode: <what it runs and writes>; pass allowCode: true to run it". The tool never asks. Pass `allowCode: true` only for a repository the user trusts: one they said they wrote or trust, or after asking them. In autonomous mode, without that word from the user, scan without it and report the gaps.
|
|
20
|
+
|
|
21
|
+
| Language | Analyzers | Needs a build |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| TypeScript | `biome`, `oxlint` (perf rules), `@e18e/depend`, `knip` | knip with project references |
|
|
24
|
+
| Python | `ruff` (SIM, PERF, FURB, UP, C4, PIE, RET, TRY, BLE, ASYNC, LOG, G, T20, ERA, F401, F841), `vulture` | no |
|
|
25
|
+
| Go | `golangci-lint` (staticcheck, unused, prealloc, perfsprint, gocritic, modernize, usestdlibvars, bodyclose, sloglint), `deadcode` | yes |
|
|
26
|
+
| Rust | `cargo clippy` (perf, complexity, suspicious, `manual_*`), `cargo-machete` | yes |
|
|
27
|
+
| All | `lizard` (cyclomatic complexity and function length) | no |
|
|
28
|
+
|
|
29
|
+
Rules:
|
|
30
|
+
- `quick` depth runs no analyzer that needs a build.
|
|
31
|
+
- A missing analyzer is a gap in the report, never an install. Install commands live in `lang-*-quality`.
|
|
32
|
+
- `challenge_scan` runs the analyzer on `PATH`, else a one-off runner at the pin in `scan/pins.ts`. When the repository pins another version of that analyzer (its lockfile or toolchain file), say so in `gaps`: rules and defaults can differ, so treat a hit or a miss as a lead. A tool that fails to start (a version shim that wants another version, a checkout with no `node_modules` or virtualenv) is a gap with the tool's error. Never run `bun install`, `npm ci`, `uv sync` or the like to fill it; ask the user to install, or report the gap.
|
|
33
|
+
- Zero hits from a run whose tools did not start is a gap, never a clean result.
|
|
34
|
+
- Output a tool did not produce in its format is a gap, never "no findings".
|
|
35
|
+
- A hit is a lead for CHALLENGE; it becomes a finding only with its own evidence.
|
|
36
|
+
- Record per hit: tool, rule, `path:line` (null when unknown), message, `rule_enabled_in_repo` (from `ruleEnabledInRepo`).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Report and decisions schemas
|
|
2
|
+
|
|
3
|
+
Two JSON Schemas (draft 2020-12) ship beside this file. Validate before DELIVER ends and fix the file, not the schema: call `challenge_validate` with the absolute run directory. It checks `report.json` and every line of `decisions.jsonl` and lists each error with its file and line.
|
|
4
|
+
|
|
5
|
+
| File | Validates |
|
|
6
|
+
|---|---|
|
|
7
|
+
| [report.schema.json](report.schema.json) | `report.json`: the run header, a summary, and one object per finding |
|
|
8
|
+
| [decisions.schema.json](decisions.schema.json) | each line of `decisions.jsonl` |
|
|
9
|
+
|
|
10
|
+
## Finding
|
|
11
|
+
|
|
12
|
+
A finding is one root cause. When the same cause recurs, report it once: `location` is the first or clearest site, `also_at` lists the other sites, and `recurs` is the total count (one more than the length of `also_at`).
|
|
13
|
+
|
|
14
|
+
| Field | Meaning |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `id` | `F1`, `F2`, ... stable for the run |
|
|
17
|
+
| `lens` | one of the 13 lenses; see [lens-simplification.md](lens-simplification.md) and its siblings |
|
|
18
|
+
| `location` | `path` and `line` of the code challenged |
|
|
19
|
+
| `also_at` | the other `path` and `line` sites of a recurring cause; absent when `recurs` is 1 |
|
|
20
|
+
| `evidence.tier` | `proven`, `measured` or `hypothesis`; see [evidence.md](evidence.md) |
|
|
21
|
+
| `impact` | value if applied: `high`, `medium` or `low` |
|
|
22
|
+
| `blast_radius` | how much code and how many callers the change touches |
|
|
23
|
+
| `changes_contract` | true when a public signature, wire format, config key or documented behaviour changes; never `low` blast radius |
|
|
24
|
+
| `test_protection` | `protected`, `partial` or `unprotected` for simplification, library and structure findings; `not-applicable` otherwise |
|
|
25
|
+
| `refute` | the REFUTE verdict and rationale; absent at `quick` depth |
|
|
26
|
+
| `status` | `accepted`, `deferred`, `rejected` (the user said no) or `dropped` (REFUTE said DROP) |
|
|
27
|
+
| `decided_by` | `user`, or `autonomous-rule` when the autonomous acceptance rule fired |
|
|
28
|
+
|
|
29
|
+
## Decisions line
|
|
30
|
+
|
|
31
|
+
Log every decision, blocker, ambiguity, choice and inference the moment it happens, in the phase that made it. `by` is `user` for an answer the user gave, `agent` for a judgement call, `autonomous-rule` when the rule in [decide.md](decide.md) fired. A line carries the alternatives considered when there were any.
|
|
32
|
+
|
|
33
|
+
Example line:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{"ts":"2026-11-20T10:15:00Z","run_id":"20261120-101200-lib","phase":"INTAKE","kind":"inference","subject":"pluggability expected","choice":"yes","reason":"two storage providers implement StoreClient","by":"agent"}
|
|
37
|
+
```
|