@esneiderbravo/speclaw 0.1.12 → 0.1.13
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/README.md +3 -2
- package/dist/cli/commands/update.js +37 -4
- package/dist/modules/foundation/assets/docs/standards/testing-standards.template.md +27 -0
- package/dist/modules/foundation/scaffold.js +6 -2
- package/dist/modules/lawbook/assets/skills/build/SKILL.md +27 -6
- package/dist/modules/lawbook/assets/skills/draft/SKILL.md +4 -2
- package/dist/shared/install.js +16 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -189,8 +189,9 @@ without a re-init, splitting files by who owns them:
|
|
|
189
189
|
|
|
190
190
|
- **Managed files** (speclaw's workflow machinery — the skills, commands, rules,
|
|
191
191
|
and agent packs under `ai-specs/`) are **refreshed** to the new version, so
|
|
192
|
-
improvements actually reach your project. If you edited one locally,
|
|
193
|
-
|
|
192
|
+
improvements actually reach your project. If you edited one locally, `update`
|
|
193
|
+
reports the overwrite so you can recover your copy from git; pass `--backup` to
|
|
194
|
+
also keep a `<file>.bak`. Any `*.bak` is gitignored.
|
|
194
195
|
- **Personalized files** (your constitution and standards — `CLAUDE.md`,
|
|
195
196
|
`AGENTS.md`, `LAWS.md`, `docs/standards/*`, `docs/compass.md`,
|
|
196
197
|
`lawbook/config.yaml`) are **never auto-edited**. When a release changes their
|
|
@@ -28,6 +28,21 @@ const MIGRATIONS = [
|
|
|
28
28
|
'the feature touched)."\n' +
|
|
29
29
|
"- Preserve all project-specific wording; only apply these speclaw-authored changes.",
|
|
30
30
|
},
|
|
31
|
+
{
|
|
32
|
+
version: "0.1.13",
|
|
33
|
+
describe: "Required report structure in the testing standard (personalized file)",
|
|
34
|
+
agentPrompt: "- In docs/standards/testing-standards.md, strengthen the 'Reports' section so a " +
|
|
35
|
+
"discipline report MUST follow a fixed structure (evidence reproducible, not improvised): " +
|
|
36
|
+
"(1) a header — discipline, change, date, branch, and the environment/working directory " +
|
|
37
|
+
"the commands ran in; (2) a gates-and-results table with each check, the exact command, " +
|
|
38
|
+
"and the real result including pass/fail counts; (3) the tests added or updated and what " +
|
|
39
|
+
"each asserts; (4) a spec-scenario coverage table mapping every '#### Scenario' in the " +
|
|
40
|
+
"change's delta specs to how it was verified (a test, a gate, or a manual step); (5) an " +
|
|
41
|
+
"honest declaration of any pre-existing or unrelated failures with proof, or 'none'; " +
|
|
42
|
+
"(6) the manual steps not automated, or 'none'; (7) a one-line verdict. Keep the existing " +
|
|
43
|
+
"'test kind does not yet apply' escape hatch. If the section is missing, add it.\n" +
|
|
44
|
+
"- Preserve all project-specific wording; only apply these speclaw-authored changes.",
|
|
45
|
+
},
|
|
31
46
|
];
|
|
32
47
|
/**
|
|
33
48
|
* Update speclaw and bring the current project up to date without a full re-init:
|
|
@@ -42,6 +57,7 @@ export async function runUpdate(flags) {
|
|
|
42
57
|
const cwd = process.cwd();
|
|
43
58
|
const migrateOnly = Boolean(flags["migrate-only"]);
|
|
44
59
|
const checkOnly = Boolean(flags.check);
|
|
60
|
+
const backup = Boolean(flags.backup);
|
|
45
61
|
const winShell = process.platform === "win32";
|
|
46
62
|
if (!migrateOnly) {
|
|
47
63
|
ui.step("Checking for updates");
|
|
@@ -66,8 +82,10 @@ export async function runUpdate(flags) {
|
|
|
66
82
|
}
|
|
67
83
|
ui.ok(`Updated to ${latest}`);
|
|
68
84
|
// Re-exec the NEWLY installed binary so migrations run with the new assets
|
|
69
|
-
// and any new feature steps — not this (now-stale) process.
|
|
70
|
-
|
|
85
|
+
// and any new feature steps — not this (now-stale) process. Carry --backup
|
|
86
|
+
// through so the refresh honors it after the upgrade.
|
|
87
|
+
const reArgs = ["update", "--migrate-only", ...(backup ? ["--backup"] : [])];
|
|
88
|
+
const re = spawnSync("speclaw", reArgs, {
|
|
71
89
|
stdio: "inherit",
|
|
72
90
|
shell: winShell,
|
|
73
91
|
});
|
|
@@ -83,13 +101,18 @@ export async function runUpdate(flags) {
|
|
|
83
101
|
return;
|
|
84
102
|
}
|
|
85
103
|
}
|
|
86
|
-
applyProjectMigrations(cwd);
|
|
104
|
+
applyProjectMigrations(cwd, backup);
|
|
87
105
|
}
|
|
88
106
|
/**
|
|
89
107
|
* Additively apply the current version's content and feature steps to a project.
|
|
90
108
|
* No-op with a hint when the directory isn't a speclaw project.
|
|
109
|
+
*
|
|
110
|
+
* @param cwd - Project root to update.
|
|
111
|
+
* @param backup - When true, a locally edited managed file is copied to
|
|
112
|
+
* `<file>.bak` before it is refreshed; the default overwrites it in place
|
|
113
|
+
* (recoverable from git) and only reports the overwrite.
|
|
91
114
|
*/
|
|
92
|
-
function applyProjectMigrations(cwd) {
|
|
115
|
+
function applyProjectMigrations(cwd, backup) {
|
|
93
116
|
const initialized = fs.existsSync(path.join(cwd, "ai-specs")) || fs.existsSync(path.join(cwd, "LAWS.md"));
|
|
94
117
|
if (!initialized) {
|
|
95
118
|
ui.step("Project");
|
|
@@ -106,6 +129,7 @@ function applyProjectMigrations(cwd) {
|
|
|
106
129
|
// rewritten — those changes are handed to the user's agent below.
|
|
107
130
|
const report = scaffold(cwd, { project_name: detectProjectName(cwd) }, packs, agents, {
|
|
108
131
|
refreshManaged: true,
|
|
132
|
+
backup,
|
|
109
133
|
});
|
|
110
134
|
const changed = report.written.filter((w) => !w.includes(".gitignore"));
|
|
111
135
|
if (changed.length) {
|
|
@@ -116,10 +140,19 @@ function applyProjectMigrations(cwd) {
|
|
|
116
140
|
else {
|
|
117
141
|
ui.ok("Managed content already up to date — nothing to refresh.");
|
|
118
142
|
}
|
|
143
|
+
// A diverged managed file is always reported so the user can recover their
|
|
144
|
+
// edits; with --backup it is also kept as a `.bak`, otherwise it is overwritten
|
|
145
|
+
// in place (git holds the prior content).
|
|
119
146
|
for (const b of report.backedUp) {
|
|
120
147
|
const rel = path.relative(cwd, b);
|
|
121
148
|
ui.warn(`${c.cream(rel)} had local edits — saved as ${rel}.bak before refreshing.`);
|
|
122
149
|
}
|
|
150
|
+
const overwritten = report.refreshedDiverged.filter((f) => !report.backedUp.includes(f));
|
|
151
|
+
for (const f of overwritten) {
|
|
152
|
+
const rel = path.relative(cwd, f);
|
|
153
|
+
ui.warn(`${c.cream(rel)} had local edits — overwritten with the current version. ` +
|
|
154
|
+
`Recover from git, or re-run with ${ui.code("--backup")} to keep a .bak.`);
|
|
155
|
+
}
|
|
123
156
|
// A project several releases behind jumps straight to @latest, so apply EVERY
|
|
124
157
|
// migration newer than its recorded version — not just the next one — oldest
|
|
125
158
|
// first (sorted, so array order can't matter). Entries are cumulative: never
|
|
@@ -32,3 +32,30 @@ suppressing a linter or deleting a test.
|
|
|
32
32
|
- The mandatory spec task steps
|
|
33
33
|
([`lawbook.md`](lawbook.md)) define which manual checks
|
|
34
34
|
the agent must execute itself.
|
|
35
|
+
|
|
36
|
+
## Reports — evidence travels with the change
|
|
37
|
+
|
|
38
|
+
Every change records its testing under `lawbook/changes/<name>/reports/`, one
|
|
39
|
+
file per discipline it touched (`backend.md`, `frontend.md`, …). `build`
|
|
40
|
+
produces them; archiving is blocked until the change has at least one discipline
|
|
41
|
+
report.
|
|
42
|
+
|
|
43
|
+
Each report MUST follow a fixed structure, so the evidence is reproducible rather
|
|
44
|
+
than improvised:
|
|
45
|
+
|
|
46
|
+
1. a **header** — discipline, change, date, branch, and the environment or
|
|
47
|
+
working directory the commands ran in;
|
|
48
|
+
2. a **gates-and-results table** — each check, the exact command, and its real
|
|
49
|
+
result with pass/fail counts;
|
|
50
|
+
3. the **tests added or updated** and what each asserts (TDD evidence where it
|
|
51
|
+
applies);
|
|
52
|
+
4. a **spec-scenario coverage table** mapping every `#### Scenario` in the
|
|
53
|
+
change's delta specs to how it was verified (a test, a gate, or a manual step);
|
|
54
|
+
5. an honest declaration of any **pre-existing or unrelated failures** with proof
|
|
55
|
+
they are not caused by the change — or "none";
|
|
56
|
+
6. the **manual steps not automated** — or "none";
|
|
57
|
+
7. a one-line **verdict**.
|
|
58
|
+
|
|
59
|
+
When a test kind does not yet apply (e.g. no unit runner), the report says so in
|
|
60
|
+
place of that evidence and records the gates and manual verification that stood
|
|
61
|
+
in.
|
|
@@ -71,8 +71,10 @@ function renderFoundation(projectPath, vars, report) {
|
|
|
71
71
|
* @param packNames - Tool pack names to install (the spec workflow is always installed).
|
|
72
72
|
* @param agents - Agent ids to configure with symlinks + MCP; empty writes content only.
|
|
73
73
|
* @param opts - `refreshManaged: true` overwrites the managed trees (skills,
|
|
74
|
-
* commands, rules, agents) with the current version
|
|
75
|
-
* `<file>.bak
|
|
74
|
+
* commands, rules, agents) with the current version; `backup: true` also keeps
|
|
75
|
+
* a `<file>.bak` of any locally edited managed file before overwriting it (the
|
|
76
|
+
* default overwrites in place — git preserves the prior content). Default
|
|
77
|
+
* (init) is additive — existing files are kept.
|
|
76
78
|
* @returns The install report augmented with the ordered next steps to run.
|
|
77
79
|
* @throws If `projectPath` does not exist, or any pack name is unknown.
|
|
78
80
|
*/
|
|
@@ -91,6 +93,7 @@ export function scaffold(projectPath, profile, packNames, agents = [], opts = {}
|
|
|
91
93
|
const record = {};
|
|
92
94
|
const managedOpts = {
|
|
93
95
|
overwrite: Boolean(opts.refreshManaged),
|
|
96
|
+
backup: Boolean(opts.backup),
|
|
94
97
|
projectPath,
|
|
95
98
|
baselines: readManifest(projectPath)?.baselines ?? {},
|
|
96
99
|
record,
|
|
@@ -100,6 +103,7 @@ export function scaffold(projectPath, profile, packNames, agents = [], opts = {}
|
|
|
100
103
|
for (const name of packNames)
|
|
101
104
|
installPack(projectPath, name, vars, report, managedOpts); // managed
|
|
102
105
|
ensureGitignore(projectPath, ".speclaw/", "speclaw local code Compass (never commit)", report);
|
|
106
|
+
ensureGitignore(projectPath, "*.bak", "speclaw managed-file refresh backups", report);
|
|
103
107
|
for (const id of agents)
|
|
104
108
|
configureAgent(projectPath, id, report); // only the chosen agents
|
|
105
109
|
// Record what was installed so `speclaw update` can re-apply these packs and
|
|
@@ -46,12 +46,33 @@ delegate manual testing to the user. Record what you verified.
|
|
|
46
46
|
## Step 5 — Write the discipline reports (mandatory)
|
|
47
47
|
|
|
48
48
|
Record the evidence of testing under `lawbook/changes/<name>/reports/`, one file
|
|
49
|
-
per discipline the change touched (`backend.md`, `frontend.md`, …).
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
per discipline the change touched (`backend.md`, `frontend.md`, …). Omit
|
|
50
|
+
disciplines the change did not touch; the archive is blocked until at least one
|
|
51
|
+
discipline report exists.
|
|
52
|
+
|
|
53
|
+
Each report MUST follow this structure, in order — the fixed shape is what makes
|
|
54
|
+
the evidence trustworthy and reproducible, rather than left to improvisation:
|
|
55
|
+
|
|
56
|
+
1. **Title + header** — `# <Discipline> checks — <change> (<date>)`, then a line
|
|
57
|
+
`Date · Branch · Environment/cwd` naming where the commands ran.
|
|
58
|
+
2. **Gates & results** — a `| Check | Command | Result |` table: each gate, the
|
|
59
|
+
exact command, and its real result with pass/fail counts (e.g. "62 files, 434
|
|
60
|
+
passed") and ✅/⚠️/❌. Quote real output — never paraphrase a green you did
|
|
61
|
+
not see.
|
|
62
|
+
3. **Tests added / updated** — each new or changed test and what it asserts; note
|
|
63
|
+
TDD evidence ("failed before the fix, passes after") where it applies.
|
|
64
|
+
4. **Spec-scenario coverage** — a table mapping each `#### Scenario` in this
|
|
65
|
+
change's delta specs to how it was verified (a test id, a gate, or a manual
|
|
66
|
+
step). Every scenario must appear.
|
|
67
|
+
5. **Pre-existing / unrelated failures** — any failing check not caused by this
|
|
68
|
+
change, with proof it is pre-existing (e.g. it reproduces with the change
|
|
69
|
+
stashed) — or state "none".
|
|
70
|
+
6. **Pending manual steps** — anything not automated, stated plainly — or "none".
|
|
71
|
+
7. **Verdict** — one line.
|
|
72
|
+
|
|
73
|
+
If a test kind does not yet apply (e.g. no unit runner), the report says so in
|
|
74
|
+
place of that evidence and records the gates and manual verification that stood
|
|
75
|
+
in.
|
|
55
76
|
|
|
56
77
|
## Step 6 — Hand off
|
|
57
78
|
|
|
@@ -54,8 +54,10 @@ Create under `lawbook/changes/<name>/`:
|
|
|
54
54
|
updated; archive within the PR).
|
|
55
55
|
- **reports/** — create the folder with a short `reports/README.md` naming the
|
|
56
56
|
discipline reports (`backend.md`, `frontend.md`, … as relevant) that `build`
|
|
57
|
-
will fill
|
|
58
|
-
|
|
57
|
+
will fill, following the required report structure (header · gates table ·
|
|
58
|
+
tests added · spec-scenario coverage · pre-existing failures · pending manual ·
|
|
59
|
+
verdict — see the `build` skill, Step 5). Every change ships this folder;
|
|
60
|
+
archive is blocked until it holds at least one discipline report.
|
|
59
61
|
|
|
60
62
|
## Step 4 — Validate
|
|
61
63
|
|
package/dist/shared/install.js
CHANGED
|
@@ -4,7 +4,14 @@ import path from "node:path";
|
|
|
4
4
|
import { render } from "./render.js";
|
|
5
5
|
/** Create a fresh, empty {@link InstallReport} to accumulate results into. */
|
|
6
6
|
export function emptyReport() {
|
|
7
|
-
return {
|
|
7
|
+
return {
|
|
8
|
+
written: [],
|
|
9
|
+
skipped: [],
|
|
10
|
+
refreshedDiverged: [],
|
|
11
|
+
backedUp: [],
|
|
12
|
+
symlinks: [],
|
|
13
|
+
unresolvedVars: [],
|
|
14
|
+
};
|
|
8
15
|
}
|
|
9
16
|
/** SHA-256 of a file's intended content, used to track managed-file baselines. */
|
|
10
17
|
export function sha256(content) {
|
|
@@ -60,9 +67,14 @@ export function copyRendered(srcDir, destDir, vars, report, opts) {
|
|
|
60
67
|
}
|
|
61
68
|
const baseline = opts.baselines?.[rel];
|
|
62
69
|
if (!baseline || sha256(current) !== baseline) {
|
|
63
|
-
// Diverged from what we last wrote (or unknown)
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
// Diverged from what we last wrote (or unknown). Record it so update can
|
|
71
|
+
// report it; keep a `.bak` only when asked — git already preserves the
|
|
72
|
+
// prior content, so the backup is opt-in, not the default.
|
|
73
|
+
if (opts.backup) {
|
|
74
|
+
fs.copyFileSync(dest, dest + ".bak");
|
|
75
|
+
report.backedUp.push(dest);
|
|
76
|
+
}
|
|
77
|
+
report.refreshedDiverged.push(dest);
|
|
66
78
|
}
|
|
67
79
|
fs.writeFileSync(dest, content);
|
|
68
80
|
}
|