@bendyline/gilde 0.1.80 → 0.1.82
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/authoring/chat-models/qwen3.8-27b-q4.json +27 -9
- package/authoring/tactical/books/bug-fix-tdd.json +2 -2
- package/authoring/tactical/books/dependency-upgrade.json +1 -1
- package/authoring/tactical/books/refactor-module.json +4 -4
- package/authoring/tactical/books/test-suite-backfill.json +2 -2
- package/authoring/tactical/wave.json +8 -8
- package/data/chat-models/index.json +1 -1
- package/data/chat-models/qw/qwen3.8-27b-q4/manifest.json +35 -12
- package/data/chat-models/qw/qwen3.8-27b-q4/versions/1.0.5/manifest.json +116 -0
- package/data/chat-models/raw-index.json +1 -1
- package/data/craftbook-templates/bu/bug-fix-tdd/versions/2.0.5/craftbook.json +736 -0
- package/data/craftbook-templates/bu/bug-fix-tdd/versions/2.0.5/test.json +221 -0
- package/data/craftbook-templates/de/dependency-upgrade/versions/1.0.5/craftbook.json +625 -0
- package/data/craftbook-templates/de/dependency-upgrade/versions/1.0.5/test.json +235 -0
- package/data/craftbook-templates/index.json +1 -1
- package/data/craftbook-templates/po/powerpoint-deck/versions/1.7.16/craftbook.json +485 -0
- package/data/craftbook-templates/po/powerpoint-deck/versions/1.7.16/test.json +265 -0
- package/data/craftbook-templates/raw-index.json +1 -1
- package/data/craftbook-templates/re/refactor-module/versions/2.0.5/craftbook.json +699 -0
- package/data/craftbook-templates/re/refactor-module/versions/2.0.5/test.json +241 -0
- package/data/craftbook-templates/te/test-suite-backfill/versions/2.0.5/craftbook.json +596 -0
- package/data/craftbook-templates/te/test-suite-backfill/versions/2.0.5/test.json +195 -0
- package/package.json +1 -1
- package/schemas/craftbook-doc.schema.json +15 -0
- package/schemas/craftbook-template-version.schema.json +15 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"title": "Behavior-preserving extraction of duplicated logic",
|
|
4
|
+
"objective": "The craftbook drives a disciplined refactor of copy-pasted name-normalization logic: a green baseline recorded before anything moves, reversible stages with the suite green throughout, a re-measured duplication target, and an enforced review — verified mechanically via a reference matrix across both call sites, a duplication count across src/, and a green-suite run.",
|
|
5
|
+
"tags": [
|
|
6
|
+
"code",
|
|
7
|
+
"refactor",
|
|
8
|
+
"tactical-fleet"
|
|
9
|
+
],
|
|
10
|
+
"prompt": "Use the Behavior-Preserving Refactor craftbook for this: the same name-normalization logic is copy-pasted in src/format-name.js and src/report.js, and the copies have drifted once already. The brief is in source/refactor-brief.md. Extract the shared logic into a new src/normalize-name.js used by both files, without changing behavior.",
|
|
11
|
+
"setup": {
|
|
12
|
+
"projectName": "Crewlog",
|
|
13
|
+
"about": "A tiny crew-hours logging module. Tests run with `npm run test` (node --test).",
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "package.json",
|
|
17
|
+
"content": "{\n \"name\": \"crewlog\",\n \"private\": true,\n \"version\": \"1.0.0\",\n \"type\": \"module\",\n \"scripts\": {\n \"test\": \"node --test\"\n }\n}\n"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"path": "src/format-name.js",
|
|
21
|
+
"content": "export function formatName(raw) {\n const words = String(raw).trim().split(/\\s+/);\n const fixed = [];\n for (const word of words) {\n fixed.push(word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());\n }\n return fixed.join(' ');\n}\n"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "src/report.js",
|
|
25
|
+
"content": "function titleCaseName(raw) {\n const words = String(raw).trim().split(/\\s+/);\n const fixed = [];\n for (const word of words) {\n fixed.push(word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());\n }\n return fixed.join(' ');\n}\n\nexport function reportLine(entry) {\n return titleCaseName(entry.name) + ': ' + entry.hours + 'h';\n}\n\nexport function reportSummary(entries) {\n return entries.map((entry) => reportLine(entry)).join('\\n');\n}\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "tests/format.test.mjs",
|
|
29
|
+
"content": "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\nimport { formatName } from '../src/format-name.js';\n\ntest('formats a messy name', () => {\n assert.equal(formatName(' ada lovelace '), 'Ada Lovelace');\n});\n"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "tests/report.test.mjs",
|
|
33
|
+
"content": "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\nimport { reportLine } from '../src/report.js';\n\ntest('report line normalizes the name', () => {\n assert.equal(reportLine({ name: 'grace hopper', hours: 2 }), 'Grace Hopper: 2h');\n});\n"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "source/refactor-brief.md",
|
|
37
|
+
"content": "# Refactor brief\n\nThe same name-normalization logic (trim, collapse inner whitespace, title-case each word) is copy-pasted in two places:\n\n- src/format-name.js - `formatName`, used by the profile screens\n- src/report.js - a private `titleCaseName` helper feeding `reportLine`\n\nThe copies drifted once before and had to be manually re-synced. Extract the shared logic into a NEW `src/normalize-name.js` module used by both files, WITHOUT changing behavior. Every output must stay byte-for-byte identical, including edge cases: extra inner spaces, ALL-CAPS input, single letters, and the empty string. Public exports must survive unchanged: `formatName`, `reportLine`, and `reportSummary` keep their names and signatures.\n"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "tests/verify-refactor.mjs",
|
|
41
|
+
"content": "import assert from 'node:assert/strict';\nimport { execFileSync } from 'node:child_process';\nimport { readFileSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { formatName } from '../src/format-name.js';\nimport { reportLine, reportSummary } from '../src/report.js';\n\n// 1) Behavior: a reference matrix across BOTH call sites, quirks included.\nconst matrix = [\n [' ada lovelace ', 'Ada Lovelace'],\n ['GRACE HOPPER', 'Grace Hopper'],\n ['katherine g. johnson', 'Katherine G. Johnson'],\n ['a', 'A'],\n ['', ''],\n];\nfor (const [input, expected] of matrix) {\n assert.equal(formatName(input), expected, 'formatName(' + JSON.stringify(input) + ')');\n}\nassert.equal(reportLine({ name: ' grace HOPPER ', hours: 4 }), 'Grace Hopper: 4h');\nassert.equal(reportLine({ name: 'ada lovelace', hours: 2 }), 'Ada Lovelace: 2h');\nassert.equal(\n reportSummary([\n { name: 'ADA LOVELACE', hours: 1 },\n { name: ' mary jackson ', hours: 3 },\n ]),\n 'Ada Lovelace: 1h\\nMary Jackson: 3h',\n);\nconsole.log('REFACTOR_MODULE_ORACLE behavior ok');\n\n// 2) Deduplication: the title-case implementation exists at most once\n// across src/ - two surviving copies mean the extraction did not happen.\nconst root = process.cwd();\nfunction countMarker(relDir) {\n let count = 0;\n for (const entry of readdirSync(join(root, relDir), { withFileTypes: true })) {\n const relPath = relDir + '/' + entry.name;\n if (entry.isDirectory()) {\n count += countMarker(relPath);\n } else if (/\\.(js|mjs|cjs|ts)$/.test(entry.name)) {\n const text = readFileSync(join(root, relPath), 'utf8');\n count += (text.match(/toUpperCase/g) ?? []).length;\n }\n }\n return count;\n}\nconst occurrences = countMarker('src');\nassert.ok(\n occurrences <= 1,\n 'the title-case implementation appears ' + occurrences + ' times across src/ - the duplication was not extracted to one shared place',\n);\nconsole.log('REFACTOR_MODULE_ORACLE dedupe ok');\n\n// 3) The whole suite is green on the refactored tree (real run).\nfunction runSuite(cwd) {\n try {\n execFileSync(process.execPath, ['--test'], { cwd, stdio: 'pipe', timeout: 30000 });\n return 0;\n } catch (err) {\n return typeof err.status === 'number' ? err.status : 1;\n }\n}\nassert.equal(runSuite(root), 0, 'the suite must be green on the refactored tree');\nconsole.log('REFACTOR_MODULE_ORACLE suite green');\nconsole.log('REFACTOR_MODULE_ORACLE done');\n",
|
|
42
|
+
"surface": "harness"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"craftbookParams": {
|
|
46
|
+
"scope": "Extract the duplicated name normalization in src/format-name.js and src/report.js into a shared src/normalize-name.js used by both, without changing behavior; see source/refactor-brief.md."
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"mocks": [],
|
|
50
|
+
"success": {
|
|
51
|
+
"summary": "The duplicated normalization lives in exactly one place, both call sites behave byte-for-byte as before (reference matrix), the suite is green on a real run, and every fleet artifact exists with honest citations.",
|
|
52
|
+
"deliverables": [
|
|
53
|
+
{
|
|
54
|
+
"path": "{{task.dir}}/baseline.md",
|
|
55
|
+
"kind": "markdown-notes",
|
|
56
|
+
"artifact": true,
|
|
57
|
+
"minBytes": 500,
|
|
58
|
+
"checks": [
|
|
59
|
+
{
|
|
60
|
+
"kind": "contains",
|
|
61
|
+
"file": "{{task.dir}}/baseline.md",
|
|
62
|
+
"pattern": "^##\\s+Current behavior[\\s\\S]*^##\\s+Measurements[\\s\\S]*^##\\s+Guardrail",
|
|
63
|
+
"flags": "im",
|
|
64
|
+
"label": "baseline sections in order"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"kind": "citationsResolve",
|
|
68
|
+
"file": "{{task.dir}}/baseline.md",
|
|
69
|
+
"minCitations": 2,
|
|
70
|
+
"artifact": true
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"path": "{{task.dir}}/plan.md",
|
|
76
|
+
"kind": "markdown-notes",
|
|
77
|
+
"artifact": true,
|
|
78
|
+
"minBytes": 500,
|
|
79
|
+
"checks": [
|
|
80
|
+
{
|
|
81
|
+
"kind": "contains",
|
|
82
|
+
"file": "{{task.dir}}/plan.md",
|
|
83
|
+
"pattern": "^##\\s+Target[\\s\\S]*^##\\s+Stages[\\s\\S]*^##\\s+Acceptance criteria",
|
|
84
|
+
"flags": "im",
|
|
85
|
+
"label": "plan sections in order"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"kind": "citationsResolve",
|
|
89
|
+
"file": "{{task.dir}}/plan.md",
|
|
90
|
+
"minCitations": 2,
|
|
91
|
+
"artifact": true
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"path": "{{task.dir}}/change-notes.md",
|
|
97
|
+
"kind": "markdown-notes",
|
|
98
|
+
"artifact": true,
|
|
99
|
+
"minBytes": 600,
|
|
100
|
+
"checks": [
|
|
101
|
+
{
|
|
102
|
+
"kind": "contains",
|
|
103
|
+
"file": "{{task.dir}}/change-notes.md",
|
|
104
|
+
"pattern": "^##\\s+Stages executed[\\s\\S]*^##\\s+Files touched[\\s\\S]*^##\\s+Deviations from plan",
|
|
105
|
+
"flags": "im",
|
|
106
|
+
"label": "change-notes sections in order"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"kind": "citationsResolve",
|
|
110
|
+
"file": "{{task.dir}}/change-notes.md",
|
|
111
|
+
"minCitations": 2,
|
|
112
|
+
"artifact": true
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"path": "{{task.dir}}/verification.md",
|
|
118
|
+
"kind": "markdown-notes",
|
|
119
|
+
"artifact": true,
|
|
120
|
+
"minBytes": 400,
|
|
121
|
+
"checks": [
|
|
122
|
+
{
|
|
123
|
+
"kind": "contains",
|
|
124
|
+
"file": "{{task.dir}}/verification.md",
|
|
125
|
+
"pattern": "^##\\s+Before\\s*/\\s*after[\\s\\S]*^##\\s+Suite[\\s\\S]*^##\\s+Result",
|
|
126
|
+
"flags": "im",
|
|
127
|
+
"label": "verification sections in order"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"kind": "contains",
|
|
131
|
+
"file": "{{task.dir}}/verification.md",
|
|
132
|
+
"pattern": "^##\\s+Before\\s*/\\s*after[\\s\\S]*\\d",
|
|
133
|
+
"flags": "im",
|
|
134
|
+
"label": "before/after figures quoted"
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"path": "{{task.dir}}/review.md",
|
|
140
|
+
"kind": "markdown-report",
|
|
141
|
+
"artifact": true,
|
|
142
|
+
"minBytes": 400,
|
|
143
|
+
"checks": [
|
|
144
|
+
{
|
|
145
|
+
"kind": "contains",
|
|
146
|
+
"file": "{{task.dir}}/review.md",
|
|
147
|
+
"pattern": "Verdict:\\s*(?:PASS|REVISE)",
|
|
148
|
+
"flags": "i",
|
|
149
|
+
"label": "explicit reviewer verdict"
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"checks": [
|
|
155
|
+
{
|
|
156
|
+
"kind": "notContains",
|
|
157
|
+
"file": "src/format-name.js",
|
|
158
|
+
"pattern": "toUpperCase",
|
|
159
|
+
"label": "format-name.js no longer carries its own title-case copy"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"kind": "notContains",
|
|
163
|
+
"file": "src/report.js",
|
|
164
|
+
"pattern": "toUpperCase",
|
|
165
|
+
"label": "report.js no longer carries its own title-case copy"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"kind": "sourceParses",
|
|
169
|
+
"file": "src/format-name.js"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"kind": "sourceParses",
|
|
173
|
+
"file": "src/report.js"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"kind": "nodeScriptPasses",
|
|
177
|
+
"script": "tests/verify-refactor.mjs",
|
|
178
|
+
"timeoutMs": 60000,
|
|
179
|
+
"requiredOutput": [
|
|
180
|
+
{
|
|
181
|
+
"pattern": "REFACTOR_MODULE_ORACLE behavior ok",
|
|
182
|
+
"label": "both call sites match the reference matrix"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"pattern": "REFACTOR_MODULE_ORACLE dedupe ok",
|
|
186
|
+
"label": "the implementation exists at most once across src/"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"pattern": "REFACTOR_MODULE_ORACLE suite green",
|
|
190
|
+
"label": "suite green on the refactored tree"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"taskNotes": {
|
|
196
|
+
"minBytes": 120,
|
|
197
|
+
"checks": [
|
|
198
|
+
{
|
|
199
|
+
"kind": "contains",
|
|
200
|
+
"file": "task-notes.md",
|
|
201
|
+
"pattern": "\\bDONE\\b[\\s\\S]*(npm\\s+run\\s+test|node\\s+--test)",
|
|
202
|
+
"flags": "i",
|
|
203
|
+
"label": "DONE note names the real test command"
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
"taskGraph": {
|
|
208
|
+
"requireCraftbookTask": true,
|
|
209
|
+
"requireTerminalStep": true
|
|
210
|
+
},
|
|
211
|
+
"unchangedFixtures": [
|
|
212
|
+
"source/refactor-brief.md",
|
|
213
|
+
"package.json"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
"rubric": {
|
|
217
|
+
"artifact": {
|
|
218
|
+
"path": "{{task.dir}}/change-notes.md",
|
|
219
|
+
"kind": "markdown"
|
|
220
|
+
},
|
|
221
|
+
"axes": [
|
|
222
|
+
{
|
|
223
|
+
"name": "Guardrail-first discipline",
|
|
224
|
+
"description": "The suite was genuinely run and recorded green before any restructuring, characterization coverage was considered honestly, and the baseline counted the duplication with a stated method."
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"name": "Reversible-stage execution",
|
|
228
|
+
"description": "The restructure happened in small planned stages at the real sites, with the suite kept green between stages and deviations recorded honestly rather than papered over."
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "Genuine deduplication",
|
|
232
|
+
"description": "One shared implementation remains, both call sites use it, public exports survived unchanged, and no behavior change was smuggled in under cover of the refactor."
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
"qualityFocus": [
|
|
237
|
+
"green-before/green-after receipts",
|
|
238
|
+
"same-method re-measurement",
|
|
239
|
+
"enforced review loop"
|
|
240
|
+
]
|
|
241
|
+
}
|