@brunosps00/dev-workflow 1.4.0 → 1.5.0
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/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -4
- package/lib/constants.js +2 -0
- package/lib/hooks.js +53 -11
- package/lib/init.js +49 -1
- package/package.json +1 -1
- package/scaffold/config/stack-mappings.json +40 -0
- package/scaffold/en/commands/dw-analyze-project.md +5 -1
- package/scaffold/en/commands/dw-context-budget.md +9 -0
- package/scaffold/en/commands/dw-harness-audit.md +3 -0
- package/scaffold/en/commands/dw-learn.md +41 -0
- package/scaffold/en/commands/dw-plan.md +2 -0
- package/scaffold/en/commands/dw-review.md +1 -0
- package/scaffold/en/commands/dw-run.md +1 -0
- package/scaffold/pt-br/commands/dw-analyze-project.md +5 -1
- package/scaffold/pt-br/commands/dw-context-budget.md +9 -0
- package/scaffold/pt-br/commands/dw-harness-audit.md +3 -0
- package/scaffold/pt-br/commands/dw-learn.md +41 -0
- package/scaffold/pt-br/commands/dw-plan.md +2 -0
- package/scaffold/pt-br/commands/dw-review.md +1 -0
- package/scaffold/pt-br/commands/dw-run.md +1 -0
- package/scaffold/rules/README.md +22 -0
- package/scaffold/rules/common.md +29 -0
- package/scaffold/rules/csharp.md +18 -0
- package/scaffold/rules/python.md +18 -0
- package/scaffold/rules/react.md +18 -0
- package/scaffold/rules/rust.md +18 -0
- package/scaffold/rules/typescript.md +23 -0
- package/scaffold/rules-readme.md +8 -0
- package/scaffold/scripts/hooks/session-cost.mjs +126 -0
- package/scaffold/scripts/hooks/statusline.mjs +31 -0
- package/scaffold/scripts/lib/model-prices.json +12 -0
- package/scaffold/skills/dw-cli-run/SKILL.md +3 -1
- package/scaffold/skills/dw-codebase-intel/SKILL.md +3 -1
- package/scaffold/skills/dw-debug-protocol/SKILL.md +4 -0
- package/scaffold/skills/dw-debug-protocol/references/agent-degradation.md +30 -0
- package/scaffold/skills/dw-execute-phase/SKILL.md +13 -0
- package/scaffold/skills/dw-git-discipline/SKILL.md +1 -0
- package/scaffold/skills/dw-llm-eval/SKILL.md +12 -0
- package/scaffold/skills/dw-memory/SKILL.md +12 -1
- package/scaffold/skills/dw-memory/references/instincts.md +45 -0
- package/scaffold/skills/dw-review-rigor/SKILL.md +12 -0
- package/scaffold/skills/dw-review-rigor/references/false-positives.md +21 -0
- package/scaffold/skills/dw-review-rigor/references/self-eval-rubric.md +38 -0
- package/scaffold/skills/dw-silent-failure/SKILL.md +4 -2
- package/scaffold/skills/dw-simplification/SKILL.md +13 -0
- package/scaffold/skills/dw-simplification/references/dead-code-tools.md +23 -0
- package/scaffold/skills/dw-testing-discipline/SKILL.md +17 -0
- package/scaffold/skills/dw-ui-discipline/SKILL.md +1 -1
- package/scaffold/skills/dw-verify/SKILL.md +1 -1
- package/scaffold/skills/dw-verify/references/pre-check-and-status.md +28 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dev-workflow",
|
|
3
3
|
"description": "Standalone, à-la-carte skills from the dev-workflow pipeline: minimalism, search-first, simplification, verification, security review, and more.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Bruno Santos"
|
|
7
7
|
},
|
package/README.md
CHANGED
|
@@ -12,11 +12,11 @@ This will:
|
|
|
12
12
|
1. Ask you to select a language (English or Portuguese)
|
|
13
13
|
2. Create `.dw/commands/` with workflow commands
|
|
14
14
|
3. Create `.dw/templates/` with document templates (PRD, TechSpec, Tasks, ADR, etc.)
|
|
15
|
-
4. Create `.dw/rules/` (populated by `/dw-analyze-project`)
|
|
15
|
+
4. Create `.dw/rules/` (populated by `/dw-analyze-project`) + a curated `.dw/rules-library/` declarative baseline per stack (loaded lazily via `.dw/config/stack-mappings.json`)
|
|
16
16
|
5. Install bundled skills (`dw-verify`, `dw-memory`, `dw-review-rigor`, `dw-ui-discipline`, `dw-testing-discipline`, `security-review`, etc.) to `.agents/skills/`
|
|
17
17
|
6. Generate skill wrappers and project agents for Claude Code, Codex, Copilot, and OpenCode
|
|
18
18
|
7. Configure MCP servers (Context7 + Playwright)
|
|
19
|
-
8. Install enforcement hooks (git guardrails) + a statusline into `.claude/settings.json` (merge-aware — your own hooks/statusline are never overwritten)
|
|
19
|
+
8. Install enforcement hooks (git guardrails + a `SessionEnd` token-cost tracker → `.dw/metrics/costs.jsonl`) + a statusline (branch · active spec · minimalism mode · today's estimated spend) into `.claude/settings.json` (merge-aware — your own hooks/statusline are never overwritten)
|
|
20
20
|
|
|
21
21
|
> **Compozy-inspired disciplines.** Since 0.5.0, dev-workflow bundles three primitives — `dw-verify`, `dw-memory`, `dw-review-rigor` — adapted from the [Compozy](https://github.com/compozy/compozy) project and invoked internally by existing commands. See [docs/compozy-integration.md](docs/compozy-integration.md) for what was ported and what was not.
|
|
22
22
|
|
|
@@ -42,7 +42,7 @@ Exportable skills (no `.dw/` pipeline required): `dw-minimalism`, `dw-search-fir
|
|
|
42
42
|
|
|
43
43
|
## Commands
|
|
44
44
|
|
|
45
|
-
dev-workflow v1.
|
|
45
|
+
dev-workflow v1.5.0 ships **37 commands** organized into four tiers. Most users only invoke Tier 1 + Tier 2.
|
|
46
46
|
|
|
47
47
|
### Tier 1 — Gateway (3)
|
|
48
48
|
|
|
@@ -69,7 +69,7 @@ Use these when you want step-by-step control instead of `/dw-autopilot`.
|
|
|
69
69
|
| **`/dw-commit`** | Atomic Conventional Commits for pending changes. Applies `dw-git-discipline` (one intent per commit, lint+tests+build green before). |
|
|
70
70
|
| **`/dw-generate-pr [target]`** | Push the branch, draft a PR body with summary + test plan, open the browser. Hard gates: dw-verify PASS + secure-audit. |
|
|
71
71
|
|
|
72
|
-
### Tier 3 — Specialty (
|
|
72
|
+
### Tier 3 — Specialty (12)
|
|
73
73
|
|
|
74
74
|
| Command | What |
|
|
75
75
|
|---------|------|
|
|
@@ -80,6 +80,7 @@ Use these when you want step-by-step control instead of `/dw-autopilot`.
|
|
|
80
80
|
| **`/dw-context-budget`** | Audits context overhead from commands, skills, agents, instruction files, and MCPs. |
|
|
81
81
|
| **`/dw-harness-audit`** | Deterministic health scorecard for the dev-workflow install, agents, wrappers, MCPs, and gates. |
|
|
82
82
|
| **`/dw-skill-health`** | Audits installed skills and agents for bloat, duplication, and missing references. |
|
|
83
|
+
| **`/dw-learn`** | Synthesizes durable decisions (confidence-tagged), bugfixes, deviations, and git history into atomic confidence-weighted **instincts** you approve at `.dw/memory/instincts/`; can propose constitution principles. On-demand and human-in-the-loop — **no always-on observer**. |
|
|
83
84
|
| **`/dw-new-project`** | Bootstrap a new project from empty directory. Stack interview, wraps official `create-*` tools, composes docker-compose for dev, seeds `.env`, scripts, CI, `.dw/rules/`. |
|
|
84
85
|
| **`/dw-dockerize`** | Reads existing project, detects stack + runtime deps, proposes Dockerfile + docker-compose for dev/prod with explicit trade-offs (Conservative/Balanced/Bold). |
|
|
85
86
|
| **`/dw-install-azure-skills`** | **Opt-in.** Clones curated Azure skills from [`MicrosoftDocs/Agent-Skills`](https://github.com/MicrosoftDocs/Agent-Skills) (CC-BY-4.0) into `.agents/skills/azure/` and registers the [Microsoft Learn MCP Server](https://learn.microsoft.com/en-us/training/support/mcp-get-started) (HTTP, no-auth). Interactive category selection (Compute / Data & Storage / AI & ML / Networking / Identity & Security / DevOps / Observability / Integration / Architecture / All). Re-run to refresh from upstream. Also available as CLI: `npx @brunosps00/dev-workflow install-azure-skills`. |
|
package/lib/constants.js
CHANGED
|
@@ -20,6 +20,7 @@ const COMMANDS = {
|
|
|
20
20
|
{ name: 'dw-install-aws-skills', description: 'Trigger when user asks to install AWS expertise, setup AWS MCP server, or add AWS agent skills. Opt-in: clones curated skills from aws/agent-toolkit-for-aws into .agents/skills/aws/ and registers the unified AWS MCP Server (stdio via mcp-proxy-for-aws). Requires uv, aws cli, and AWS credentials.' },
|
|
21
21
|
{ name: 'dw-install-azure-skills', description: 'Trigger when user asks to install Azure expertise, setup Microsoft docs MCP, or add Azure agent skills. Opt-in: clones curated skills from MicrosoftDocs/Agent-Skills into .agents/skills/azure/ and registers the Microsoft Learn MCP server.' },
|
|
22
22
|
{ name: 'dw-intel', description: 'Codebase intelligence: query mode (default) answers questions citing .dw/intel/ + .dw/rules/; --build mode (re)builds the index.' },
|
|
23
|
+
{ name: 'dw-learn', description: 'Synthesizes durable decisions, bugfixes, deviations, and git history into atomic confidence-weighted instincts you approve; can propose constitution principles. On-demand and human-in-the-loop — no always-on observer.' },
|
|
23
24
|
{ name: 'dw-new-project', description: 'Interviews you about stack and infra, then scaffolds a working monorepo with docker-compose for dev, .env, scripts, CI, and seeded rules.' },
|
|
24
25
|
{ name: 'dw-opportunities', description: 'Scans the installed project for product, UX, automation, refactor, and security opportunities, then routes each idea to the right next dw-* command.' },
|
|
25
26
|
{ name: 'dw-pause', description: 'Trigger when user says "pause work", "end session", or "save where we are". Consolidates open loops, decisions, blockers, and todos into .dw/STATE.md so the next session can resume.' },
|
|
@@ -58,6 +59,7 @@ const COMMANDS = {
|
|
|
58
59
|
{ name: 'dw-install-aws-skills', description: 'Trigger quando usuario pede pra instalar expertise AWS, configurar MCP da AWS, ou adicionar agent skills AWS. Opt-in: clona skills curadas de aws/agent-toolkit-for-aws para .agents/skills/aws/ e registra o AWS MCP Server unificado (stdio via mcp-proxy-for-aws). Requer uv, aws cli e credenciais AWS.' },
|
|
59
60
|
{ name: 'dw-install-azure-skills', description: 'Trigger quando usuario pede pra instalar expertise Azure, configurar MCP do Microsoft docs, ou adicionar agent skills Azure. Opt-in: clona skills curadas de MicrosoftDocs/Agent-Skills para .agents/skills/azure/ e registra o Microsoft Learn MCP server.' },
|
|
60
61
|
{ name: 'dw-intel', description: 'Inteligencia do codebase: modo query (default) responde citando .dw/intel/ + .dw/rules/; modo --build (re)constroi indice.' },
|
|
62
|
+
{ name: 'dw-learn', description: 'Sintetiza decisoes duraveis, bugfixes, deviations e historico git em instincts atomicos ponderados por confianca que voce aprova; pode propor principios de constitution. On-demand e human-in-the-loop — sem observador sempre-ligado.' },
|
|
61
63
|
{ name: 'dw-new-project', description: 'Entrevista voce sobre stack e infra, depois faz scaffold de um monorepo com docker-compose para dev, .env, scripts, CI e rules seed.' },
|
|
62
64
|
{ name: 'dw-opportunities', description: 'Escaneia o projeto instalado por oportunidades de produto, UX, automacao, refactor e seguranca, e roteia cada ideia para o proximo comando dw-* correto.' },
|
|
63
65
|
{ name: 'dw-pause', description: 'Trigger quando usuario diz "pausa o trabalho", "encerra a sessao" ou "salva onde paramos". Consolida pontas soltas, decisoes, bloqueios e todos em .dw/STATE.md para a proxima sessao retomar.' },
|
package/lib/hooks.js
CHANGED
|
@@ -7,6 +7,8 @@ const HOOKS_DIR_MARKER = '.dw/scripts/hooks/';
|
|
|
7
7
|
const GIT_GUARDRAILS_CMD = 'node .dw/scripts/hooks/git-guardrails.mjs';
|
|
8
8
|
const STATUSLINE_CMD = 'node .dw/scripts/hooks/statusline.mjs';
|
|
9
9
|
const GIT_GUARDRAILS_SCRIPT = 'git-guardrails.mjs';
|
|
10
|
+
const SESSION_COST_CMD = 'node .dw/scripts/hooks/session-cost.mjs';
|
|
11
|
+
const SESSION_COST_SCRIPT = 'session-cost.mjs';
|
|
10
12
|
|
|
11
13
|
function isOurs(command) {
|
|
12
14
|
return typeof command === 'string' && command.includes(HOOKS_DIR_MARKER);
|
|
@@ -31,13 +33,48 @@ function installHooks(projectRoot) {
|
|
|
31
33
|
const before = JSON.stringify(settings);
|
|
32
34
|
|
|
33
35
|
const hooksResult = reconcilePreToolUseGitGuardrails(settings);
|
|
36
|
+
const sessionCostResult = reconcileSessionEndCost(settings);
|
|
34
37
|
const statusLineResult = reconcileStatusLine(settings);
|
|
35
38
|
|
|
36
39
|
if (JSON.stringify(settings) !== before) {
|
|
37
40
|
writeSettings(projectRoot, settings);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
return { hooks: hooksResult, statusLine: statusLineResult };
|
|
43
|
+
return { hooks: hooksResult, sessionCost: sessionCostResult, statusLine: statusLineResult };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Reconcile the SessionEnd cost-tracking hook (marker-based, merge-aware — same
|
|
48
|
+
* contract as the git guardrail). No matcher: fires on every session end.
|
|
49
|
+
* Returns 'added' | 'updated' | 'unchanged'.
|
|
50
|
+
*/
|
|
51
|
+
function reconcileSessionEndCost(settings) {
|
|
52
|
+
if (!settings.hooks || typeof settings.hooks !== 'object') settings.hooks = {};
|
|
53
|
+
if (!Array.isArray(settings.hooks.SessionEnd)) settings.hooks.SessionEnd = [];
|
|
54
|
+
|
|
55
|
+
const groups = settings.hooks.SessionEnd;
|
|
56
|
+
|
|
57
|
+
const existed = groups.some(
|
|
58
|
+
(g) => g && Array.isArray(g.hooks) && g.hooks.some((h) => h && typeof h.command === 'string' && h.command.includes(SESSION_COST_SCRIPT)),
|
|
59
|
+
);
|
|
60
|
+
const exactPresent = groups.some(
|
|
61
|
+
(g) => g && Array.isArray(g.hooks) && g.hooks.some((h) => h && h.command === SESSION_COST_CMD),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (exactPresent) return 'unchanged';
|
|
65
|
+
|
|
66
|
+
// Drop any stale/relocated copies of OUR hook, preserving user hooks.
|
|
67
|
+
for (const group of groups) {
|
|
68
|
+
if (!group || !Array.isArray(group.hooks)) continue;
|
|
69
|
+
group.hooks = group.hooks.filter(
|
|
70
|
+
(h) => !(h && typeof h.command === 'string' && h.command.includes(SESSION_COST_SCRIPT)),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
settings.hooks.SessionEnd = groups.filter((g) => g && Array.isArray(g.hooks) && g.hooks.length > 0);
|
|
74
|
+
|
|
75
|
+
settings.hooks.SessionEnd.push({ hooks: [{ type: 'command', command: SESSION_COST_CMD }] });
|
|
76
|
+
|
|
77
|
+
return existed ? 'updated' : 'added';
|
|
41
78
|
}
|
|
42
79
|
|
|
43
80
|
function reconcilePreToolUseGitGuardrails(settings) {
|
|
@@ -105,17 +142,21 @@ function removeHooks(projectRoot) {
|
|
|
105
142
|
const settings = readSettings(projectRoot);
|
|
106
143
|
let removed = 0;
|
|
107
144
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
145
|
+
// Remove OUR hook entries from every event (PreToolUse, SessionEnd, PostToolUse, …),
|
|
146
|
+
// identified by the .dw/scripts/hooks/ marker; never touch user-added hooks.
|
|
147
|
+
if (settings.hooks && typeof settings.hooks === 'object') {
|
|
148
|
+
for (const event of Object.keys(settings.hooks)) {
|
|
149
|
+
const groups = settings.hooks[event];
|
|
150
|
+
if (!Array.isArray(groups)) continue;
|
|
151
|
+
for (const group of groups) {
|
|
152
|
+
if (!group || !Array.isArray(group.hooks)) continue;
|
|
153
|
+
const kept = group.hooks.filter((h) => !(h && isOurs(h.command)));
|
|
154
|
+
removed += group.hooks.length - kept.length;
|
|
155
|
+
group.hooks = kept;
|
|
156
|
+
}
|
|
157
|
+
settings.hooks[event] = groups.filter((g) => g && Array.isArray(g.hooks) && g.hooks.length > 0);
|
|
158
|
+
if (settings.hooks[event].length === 0) delete settings.hooks[event];
|
|
114
159
|
}
|
|
115
|
-
settings.hooks.PreToolUse = settings.hooks.PreToolUse.filter(
|
|
116
|
-
(g) => g && Array.isArray(g.hooks) && g.hooks.length > 0,
|
|
117
|
-
);
|
|
118
|
-
if (settings.hooks.PreToolUse.length === 0) delete settings.hooks.PreToolUse;
|
|
119
160
|
if (Object.keys(settings.hooks).length === 0) delete settings.hooks;
|
|
120
161
|
}
|
|
121
162
|
|
|
@@ -134,4 +175,5 @@ module.exports = {
|
|
|
134
175
|
HOOKS_DIR_MARKER,
|
|
135
176
|
GIT_GUARDRAILS_CMD,
|
|
136
177
|
STATUSLINE_CMD,
|
|
178
|
+
SESSION_COST_CMD,
|
|
137
179
|
};
|
package/lib/init.js
CHANGED
|
@@ -170,6 +170,30 @@ async function run({ force = false, lang = null, mode = 'init', profile = null,
|
|
|
170
170
|
console.log();
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// 3.9. Copy curated rules library + stack mappings (declarative baseline per stack,
|
|
174
|
+
// loaded lazily by the detected stack). Managed: reconciled on update/repair.
|
|
175
|
+
const rulesLibSrc = path.join(SCAFFOLD_DIR, 'rules');
|
|
176
|
+
if (require('fs').existsSync(rulesLibSrc)) {
|
|
177
|
+
console.log(' Rules library:');
|
|
178
|
+
const rlResults = copyDir(rulesLibSrc, path.join(projectRoot, '.dw', 'rules-library'), managedForce);
|
|
179
|
+
totalCreated += rlResults.created;
|
|
180
|
+
totalSkipped += rlResults.skipped;
|
|
181
|
+
totalOverwritten += rlResults.overwritten;
|
|
182
|
+
touchedFiles.push(...listFilesRecursive(path.join(projectRoot, '.dw', 'rules-library')));
|
|
183
|
+
console.log(` ${rlResults.created} created, ${rlResults.skipped} skipped, ${rlResults.overwritten} overwritten\n`);
|
|
184
|
+
}
|
|
185
|
+
const stackMapSrc = path.join(SCAFFOLD_DIR, 'config', 'stack-mappings.json');
|
|
186
|
+
if (require('fs').existsSync(stackMapSrc)) {
|
|
187
|
+
const cfgDir = path.join(projectRoot, '.dw', 'config');
|
|
188
|
+
ensureDir(cfgDir);
|
|
189
|
+
const stackMapDest = path.join(cfgDir, 'stack-mappings.json');
|
|
190
|
+
const smStatus = writeFile(stackMapDest, require('fs').readFileSync(stackMapSrc, 'utf-8'), managedForce);
|
|
191
|
+
if (smStatus === 'created') totalCreated++;
|
|
192
|
+
else if (smStatus === 'overwritten') totalOverwritten++;
|
|
193
|
+
else totalSkipped++;
|
|
194
|
+
touchedFiles.push(stackMapDest);
|
|
195
|
+
}
|
|
196
|
+
|
|
173
197
|
// 4. Create .dw/rules/ with README
|
|
174
198
|
if (!isUpdate) {
|
|
175
199
|
console.log(' Rules:');
|
|
@@ -233,6 +257,30 @@ async function run({ force = false, lang = null, mode = 'init', profile = null,
|
|
|
233
257
|
touchedFiles.push(gitkeepPath);
|
|
234
258
|
}
|
|
235
259
|
|
|
260
|
+
// 5.25. Ensure .dw/metrics/ + .gitignore (runtime cost tracking; costs.jsonl is
|
|
261
|
+
// machine-local so it is gitignored). Created if missing on both init and update.
|
|
262
|
+
{
|
|
263
|
+
const metricsDir = path.join(projectRoot, '.dw', 'metrics');
|
|
264
|
+
ensureDir(metricsDir);
|
|
265
|
+
const metricsGitignore = path.join(metricsDir, '.gitignore');
|
|
266
|
+
const mStatus = writeFile(metricsGitignore, 'costs.jsonl\n', false);
|
|
267
|
+
if (mStatus === 'created') totalCreated++;
|
|
268
|
+
else totalSkipped++;
|
|
269
|
+
touchedFiles.push(metricsGitignore);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// 5.26. Ensure .dw/memory/instincts/ (durable learnings promoted by /dw-learn;
|
|
273
|
+
// format in the dw-memory skill's references/instincts.md). Init only; preserved on update.
|
|
274
|
+
if (!isUpdate) {
|
|
275
|
+
const instinctsDir = path.join(projectRoot, '.dw', 'memory', 'instincts');
|
|
276
|
+
ensureDir(instinctsDir);
|
|
277
|
+
const instinctsKeep = path.join(instinctsDir, '.gitkeep');
|
|
278
|
+
const ikStatus = writeFile(instinctsKeep, '', false);
|
|
279
|
+
if (ikStatus === 'created') totalCreated++;
|
|
280
|
+
else totalSkipped++;
|
|
281
|
+
touchedFiles.push(instinctsKeep);
|
|
282
|
+
}
|
|
283
|
+
|
|
236
284
|
// 5.3. Create local ephemeral subtask handoff directories.
|
|
237
285
|
ensureSubtaskLayout(projectRoot);
|
|
238
286
|
touchedFiles.push(path.join(projectRoot, '.dw', 'subtasks', '.gitignore'));
|
|
@@ -317,7 +365,7 @@ async function run({ force = false, lang = null, mode = 'init', profile = null,
|
|
|
317
365
|
// refreshes our entries, never touches user-defined hooks/statusLine).
|
|
318
366
|
console.log(' Hooks & statusline:');
|
|
319
367
|
const hookResults = installHooks(projectRoot);
|
|
320
|
-
console.log(` git-guardrails: ${hookResults.hooks}, statusline: ${hookResults.statusLine}\n`);
|
|
368
|
+
console.log(` git-guardrails: ${hookResults.hooks}, session-cost: ${hookResults.sessionCost}, statusline: ${hookResults.statusLine}\n`);
|
|
321
369
|
if (hookResults.statusLine === 'skipped-user') {
|
|
322
370
|
console.log(' Note: a custom statusLine is set; to show dev-workflow state add `node .dw/scripts/hooks/statusline.mjs`.\n');
|
|
323
371
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brunosps00/dev-workflow",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "AI-driven development workflow commands for any project. Scaffolds a complete PRD-to-PR pipeline with multi-platform AI assistant support.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dev-workflow": "./bin/dev-workflow.js"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_note": "Maps a detected stack to its curated baseline rule files (in .dw/rules-library/), relevant bundled skills, and safe default permissions. Consumed by /dw-analyze-project (detect + seed constitution) and /dw-review (declarative bar). Load ONLY the active stack's rules — never the whole library. Indicators: a bare filename means 'file exists'; 'file:substring' means the file contains the substring.",
|
|
3
|
+
"stacks": [
|
|
4
|
+
{
|
|
5
|
+
"id": "typescript",
|
|
6
|
+
"indicators": ["tsconfig.json", "package.json:typescript"],
|
|
7
|
+
"rules": ["common", "typescript"],
|
|
8
|
+
"skills": ["dw-testing-discipline", "dw-simplification"],
|
|
9
|
+
"permissions": { "allow": ["npx tsc", "npx eslint", "npm test", "pnpm test"], "deny": ["npm publish"] }
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "react",
|
|
13
|
+
"indicators": ["package.json:react"],
|
|
14
|
+
"rules": ["common", "typescript", "react"],
|
|
15
|
+
"skills": ["dw-ui-discipline", "vercel-react-best-practices", "dw-testing-discipline"],
|
|
16
|
+
"permissions": { "allow": ["npm test", "pnpm test", "npx vitest"], "deny": [] }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "python",
|
|
20
|
+
"indicators": ["pyproject.toml", "requirements.txt", "setup.py"],
|
|
21
|
+
"rules": ["common", "python"],
|
|
22
|
+
"skills": ["dw-testing-discipline", "dw-silent-failure"],
|
|
23
|
+
"permissions": { "allow": ["pytest", "ruff", "mypy"], "deny": [] }
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "rust",
|
|
27
|
+
"indicators": ["Cargo.toml"],
|
|
28
|
+
"rules": ["common", "rust"],
|
|
29
|
+
"skills": ["dw-testing-discipline"],
|
|
30
|
+
"permissions": { "allow": ["cargo test", "cargo clippy", "cargo check"], "deny": [] }
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "csharp",
|
|
34
|
+
"indicators": [".csproj", ".sln"],
|
|
35
|
+
"rules": ["common", "csharp"],
|
|
36
|
+
"skills": ["dw-testing-discipline"],
|
|
37
|
+
"permissions": { "allow": ["dotnet test", "dotnet build"], "deny": [] }
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -225,6 +225,10 @@ For each module/project detected, identify:
|
|
|
225
225
|
| **Auth** | NextAuth, Passport, Keycloak, Auth0, etc. | Dependencies + auth-related files |
|
|
226
226
|
| **API Style** | REST, GraphQL, tRPC, gRPC | Route definitions, schema files |
|
|
227
227
|
|
|
228
|
+
#### Curated baseline (rules-library)
|
|
229
|
+
|
|
230
|
+
After detecting the stack(s), consult `.dw/config/stack-mappings.json`: each matched stack points to its curated baseline in `.dw/rules-library/` (`common.md` + `<stack>.md`) — the declarative "what good code looks like here" default. **Reference** these files (do NOT copy them into `.dw/rules/`): the analytical rules you write describe what the code IS; the library describes what it SHOULD be. Load only the matched stacks' files to protect the context budget.
|
|
231
|
+
|
|
228
232
|
#### Frontend Health Baseline
|
|
229
233
|
|
|
230
234
|
When React is detected, run `npx react-doctor@latest --verbose` and include the health score in the generated rules as a baseline metric.
|
|
@@ -740,7 +744,7 @@ Three options:
|
|
|
740
744
|
|
|
741
745
|
**Option A — Synthesize:**
|
|
742
746
|
|
|
743
|
-
1. Read `.dw/rules/index.md` + each `.dw/rules/{module}.md`.
|
|
747
|
+
1. Read `.dw/rules/index.md` + each `.dw/rules/{module}.md`, plus the curated baseline for the detected stack(s) in `.dw/rules-library/` (`common.md` + `<stack>.md`). A baseline principle the project already follows is a well-grounded proposal — cite the rules-library file as its evidence.
|
|
744
748
|
2. Propose 5–8 principles. Each must:
|
|
745
749
|
- Have a unique `P-NNN` ID.
|
|
746
750
|
- Map to an observation in `.dw/rules/` (cite the rule file + section).
|
|
@@ -21,6 +21,15 @@ You are the context budget auditor for dev-workflow.
|
|
|
21
21
|
- Claude/OpenCode agent files with provider-incompatible tool or permission fields.
|
|
22
22
|
4. Recommend the top 5 savings with concrete paths.
|
|
23
23
|
|
|
24
|
+
## Part B — Runtime spend (actual token cost)
|
|
25
|
+
|
|
26
|
+
Static overhead (above) is what the harness *loads*; this part is what sessions actually *cost*. Report from `.dw/metrics/costs.jsonl` (appended by the `session-cost` SessionEnd hook — one row per session with per-model token usage + estimated USD):
|
|
27
|
+
|
|
28
|
+
1. Read `.dw/metrics/costs.jsonl` if present. If absent, note "no runtime cost data yet (hook disabled or no session has ended)" and skip this part — never fail.
|
|
29
|
+
2. Dedupe by `session_id` (latest row per session wins).
|
|
30
|
+
3. Report: estimated spend today and over the last 7 days; the 3 most expensive sessions; and the per-model split (which model burned the most).
|
|
31
|
+
4. USD is a best-effort estimate from `.dw/scripts/lib/model-prices.json` — token counts are exact, prices may drift. Flag any model that resolved to `_default`/`_unknown` (missing price entry to add).
|
|
32
|
+
|
|
24
33
|
## Output
|
|
25
34
|
Write a concise report in chat. If `.dw/reports/` exists, also write `.dw/reports/context-budget.md`.
|
|
26
35
|
|
|
@@ -26,6 +26,9 @@ You are the dev-workflow harness auditor.
|
|
|
26
26
|
4. Cite missing paths, broken references, stale managed files, and skills without a structured return.
|
|
27
27
|
5. Recommend the top 3 fixes.
|
|
28
28
|
|
|
29
|
+
## Runtime degradation triage (on-demand)
|
|
30
|
+
The scorecard above is deterministic **install** health. If instead the *agent* is misbehaving at runtime (loops, objective drift, hallucinated edits, degraded reasoning), that is a different diagnosis: point the user to `.agents/skills/dw-debug-protocol/references/agent-degradation.md` (symptom→cause table + ordered recovery). Advisory only — it does not affect the scorecard.
|
|
31
|
+
|
|
29
32
|
## Output
|
|
30
33
|
Return a scorecard and do not mutate files. Tell the user to run `dev-workflow repair` for managed-file drift.
|
|
31
34
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<system_instructions>
|
|
2
|
+
You are the learning synthesizer for dev-workflow. You turn what this project's work has ALREADY recorded into atomic, confidence-weighted **instincts** the team can reuse — and you NEVER write anything without explicit approval.
|
|
3
|
+
|
|
4
|
+
## When to Use
|
|
5
|
+
- After a run of related work (a few tasks, a bugfix batch) to capture what was learned.
|
|
6
|
+
- When the user says "learn from this", "what patterns emerged", or "promote what we learned".
|
|
7
|
+
- Periodically, to propose constitution principles grounded in real, repeated practice.
|
|
8
|
+
|
|
9
|
+
Do NOT invent best practices from nothing — every instinct must be grounded in this project's records.
|
|
10
|
+
|
|
11
|
+
## Sources (read-only; there is NO always-on observer)
|
|
12
|
+
Gather signals only from what is already persisted:
|
|
13
|
+
1. `.dw/spec/*/MEMORY.md` — durable decisions, especially those tagged `[confidence: …]` (see the `dw-memory` skill).
|
|
14
|
+
2. `.dw/bugfixes/*/SUMMARY.md` — recurring root causes and the guards added.
|
|
15
|
+
3. `.dw/spec/*/deviations.md` — where the plan met reality.
|
|
16
|
+
4. Recent git history — `git log --oneline -50` and commit-message patterns.
|
|
17
|
+
5. Existing `.dw/memory/instincts/*.md` — to UPDATE confidence, not duplicate.
|
|
18
|
+
|
|
19
|
+
## Process
|
|
20
|
+
1. **Cluster** repeated signals into candidate instincts. A candidate needs **≥2 independent confirmations** (two tasks, a decision + a bugfix, a repeated commit pattern). A one-off is NOT an instinct.
|
|
21
|
+
2. **Score** each candidate's confidence (0.3–0.9) using the `dw-memory` confidence rule; name the evidence.
|
|
22
|
+
3. **Classify** `domain` (code-style / testing / error-handling / git / workflow / security) and `scope` (project by default).
|
|
23
|
+
4. **Present** candidates in chat as a markdown list — id, trigger, action, confidence, evidence. Do NOT write yet.
|
|
24
|
+
5. **Ask**: "Approve which to store? (ids, or 'all', or 'none'). Any to promote to a constitution principle?"
|
|
25
|
+
6. On approval:
|
|
26
|
+
- Write each approved instinct to `.dw/memory/instincts/<slug>.md` in the format from `.agents/skills/dw-memory/references/instincts.md` (create or update; never duplicate an existing id).
|
|
27
|
+
- For any the user chooses to promote, hand off to the constitution flow — propose a `P-NNN` principle at `severity: info` for `/dw-analyze-project` Step 8. Do NOT edit `.dw/constitution.md` directly without the user re-confirming.
|
|
28
|
+
7. Update confidence on existing instincts that new evidence reconfirms or contradicts.
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
- Never write an instinct or a constitution change without explicit approval (mirrors constitution + STATE handling).
|
|
32
|
+
- Ground every instinct in cited evidence; drop candidates you cannot ground in ≥2 confirmations.
|
|
33
|
+
- Keep instincts atomic — one trigger, one action. Split compound learnings.
|
|
34
|
+
- Project scope by default; mark `global` only when the pattern is seen across projects.
|
|
35
|
+
- This command reads and proposes; it NEVER modifies source code.
|
|
36
|
+
|
|
37
|
+
## Output
|
|
38
|
+
A list of proposed/updated instincts (id, trigger, action, confidence, evidence); then, after approval, the files written under `.dw/memory/instincts/` and any constitution proposals handed off.
|
|
39
|
+
|
|
40
|
+
Final marker: `## LEARN COMPLETE`
|
|
41
|
+
</system_instructions>
|
|
@@ -70,6 +70,8 @@ The tool is mandatory for planning because it preserves explicit user choices an
|
|
|
70
70
|
|
|
71
71
|
If `.dw/intel/` doesn't exist, fall back to `.dw/rules/` and direct grep. Suggest `/dw-intel --build` to populate intel for richer downstream context.
|
|
72
72
|
|
|
73
|
+
If `.dw/memory/instincts/` has entries, load any with confidence ≥0.7 whose `trigger` matches the feature (lazy, by trigger only) — they encode learned project conventions from `/dw-learn` worth respecting in the spec.
|
|
74
|
+
|
|
73
75
|
## Stage 1 — PRD generation
|
|
74
76
|
|
|
75
77
|
Runs when default mode OR `plan prd`.
|
|
@@ -139,6 +139,7 @@ If MISSING > 0, the verdict suggests revisiting `/dw-plan tasks` to scope or `/d
|
|
|
139
139
|
- General patterns: no `any` types in TS, no `console.log` in prod, error handling, multi-tenancy.
|
|
140
140
|
- Backend patterns from `.dw/rules/<backend>.md`: Clean Architecture, use-case return types, DTOs, parameterized queries.
|
|
141
141
|
- Frontend patterns from `.dw/rules/<frontend>.md`: Server Components default, forms patterns, design system.
|
|
142
|
+
- Curated baseline: check the diff against the active stack's `.dw/rules-library/<stack>.md` (+ `common.md`) as the declarative bar. The project's own `.dw/rules/` and `.dw/constitution.md` override it where they differ.
|
|
142
143
|
|
|
143
144
|
3. **Constitution compliance** (against `.dw/constitution.md`):
|
|
144
145
|
- For each principle, check diff for violations per the principle's Enforcement line.
|
|
@@ -31,6 +31,7 @@ When available under `./.agents/skills/`, these skills are invoked per task:
|
|
|
31
31
|
|
|
32
32
|
- `dw-verify`: **ALWAYS** — before each task's commit, produces a Verification Report (test + lint + build all GREEN). Without PASS, no commit. The Iron Law of verification.
|
|
33
33
|
- `dw-memory`: **ALWAYS** — reads workflow memory at task start; updates at task end with the promotion test (lessons that apply to next task get promoted to shared MEMORY.md).
|
|
34
|
+
- Instincts (lazy): at task start, also load any high-confidence instinct (`.dw/memory/instincts/`, confidence ≥0.7) whose `trigger` matches the task — learned project conventions promoted by `/dw-learn`. Match by trigger only; never bulk-load the set.
|
|
34
35
|
- `dw-execute-phase`: provides `plan-checker` (6-dimension goal-backward verification before any code is touched in plan mode) and `executor` (atomic commit + deviation handling) agents.
|
|
35
36
|
- `dw-testing-discipline`: applies the placement doctrine, 6 agent guardrails, and 25 anti-patterns when adding tests during the task.
|
|
36
37
|
- `dw-ui-discipline`: when the task touches UI, the 4 grounding questions must be answered before any visual decision lands.
|
|
@@ -213,6 +213,10 @@ Para cada projeto/módulo detectado, identificar:
|
|
|
213
213
|
| **Containerização** | Dockerfile, docker-compose.yml |
|
|
214
214
|
| **Monorepo tools** | Turborepo, Nx, Lerna, pnpm workspaces |
|
|
215
215
|
|
|
216
|
+
#### Baseline curada (rules-library)
|
|
217
|
+
|
|
218
|
+
Após detectar a(s) stack(s), consulte `.dw/config/stack-mappings.json`: cada stack casada aponta para sua baseline curada em `.dw/rules-library/` (`common.md` + `<stack>.md`) — o default declarativo "como um bom código se parece aqui". **Referencie** esses arquivos (NÃO copie para `.dw/rules/`): as rules analíticas que você escreve descrevem o que o código É; a library descreve o que ele DEVERIA ser. Carregue só os arquivos das stacks casadas para proteger o budget de contexto.
|
|
219
|
+
|
|
216
220
|
#### Baseline de Saúde do Frontend
|
|
217
221
|
|
|
218
222
|
Quando React for detectado, execute `npx react-doctor@latest --verbose` e inclua o health score nas rules geradas como métrica baseline.
|
|
@@ -680,7 +684,7 @@ Três opções:
|
|
|
680
684
|
|
|
681
685
|
**Opção A — Sintetizar:**
|
|
682
686
|
|
|
683
|
-
1. Ler `.dw/rules/index.md` + cada `.dw/rules/{module}.md`.
|
|
687
|
+
1. Ler `.dw/rules/index.md` + cada `.dw/rules/{module}.md`, mais a baseline curada da(s) stack(s) detectada(s) em `.dw/rules-library/` (`common.md` + `<stack>.md`). Um princípio da baseline que o projeto já segue é uma proposta bem-fundamentada — cite o arquivo da rules-library como evidência.
|
|
684
688
|
2. Propor 5–8 princípios. Cada um deve:
|
|
685
689
|
- Ter ID único `P-NNN`.
|
|
686
690
|
- Mapear para uma observação em `.dw/rules/` (citar o arquivo + seção).
|
|
@@ -21,6 +21,15 @@ Voce e o auditor de orcamento de contexto do dev-workflow.
|
|
|
21
21
|
- agentes Claude/OpenCode com campos de tools ou permissions incompativeis com o provider.
|
|
22
22
|
4. Recomende as 5 maiores economias com caminhos concretos.
|
|
23
23
|
|
|
24
|
+
## Parte B — Gasto em runtime (custo real de token)
|
|
25
|
+
|
|
26
|
+
O overhead estatico (acima) e o que o harness *carrega*; esta parte e o que as sessoes de fato *custam*. Reporte a partir de `.dw/metrics/costs.jsonl` (append pelo hook `session-cost` de SessionEnd — uma linha por sessao com uso de tokens por modelo + USD estimado):
|
|
27
|
+
|
|
28
|
+
1. Leia `.dw/metrics/costs.jsonl` se existir. Se ausente, registre "sem dados de custo runtime ainda (hook desabilitado ou nenhuma sessao encerrada)" e pule esta parte — nunca falhe.
|
|
29
|
+
2. Deduplique por `session_id` (a linha mais recente por sessao vence).
|
|
30
|
+
3. Reporte: gasto estimado hoje e nos ultimos 7 dias; as 3 sessoes mais caras; e o split por modelo (qual modelo gastou mais).
|
|
31
|
+
4. USD e estimativa best-effort de `.dw/scripts/lib/model-prices.json` — contagem de tokens e exata, precos podem defasar. Sinalize modelos que resolveram para `_default`/`_unknown` (falta entrada de preco).
|
|
32
|
+
|
|
24
33
|
## Saida
|
|
25
34
|
Responda com um relatorio conciso. Se `.dw/reports/` existir, escreva tambem `.dw/reports/context-budget.md`.
|
|
26
35
|
|
|
@@ -26,6 +26,9 @@ Voce e o auditor do harness dev-workflow.
|
|
|
26
26
|
4. Cite paths ausentes, referencias quebradas, arquivos gerenciados stale, e skills sem retorno estruturado.
|
|
27
27
|
5. Recomende os 3 principais fixes.
|
|
28
28
|
|
|
29
|
+
## Triagem de degradacao em runtime (sob demanda)
|
|
30
|
+
O scorecard acima e saude deterministica da **instalacao**. Se o problema for o *agente* se comportando mal em runtime (loops, desvio do objetivo, edicoes alucinadas, raciocinio degradado), o diagnostico e outro: aponte o usuario para `.agents/skills/dw-debug-protocol/references/agent-degradation.md` (tabela sintoma→causa + recovery ordenado). Apenas informativo — nao afeta o scorecard.
|
|
31
|
+
|
|
29
32
|
## Saida
|
|
30
33
|
Retorne um scorecard e nao altere arquivos. Para drift de arquivo gerenciado, indique `dev-workflow repair`.
|
|
31
34
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<system_instructions>
|
|
2
|
+
Voce e o sintetizador de aprendizado do dev-workflow. Voce transforma o que o trabalho deste projeto JA registrou em **instincts** atomicos e ponderados por confianca que o time pode reusar — e NUNCA escreve nada sem aprovacao explicita.
|
|
3
|
+
|
|
4
|
+
## Quando Usar
|
|
5
|
+
- Apos uma leva de trabalho relacionado (algumas tasks, um lote de bugfixes) para capturar o que foi aprendido.
|
|
6
|
+
- Quando o usuario disser "aprenda com isso", "que padroes emergiram" ou "promova o que aprendemos".
|
|
7
|
+
- Periodicamente, para propor principios de constitution fundamentados em pratica real e repetida.
|
|
8
|
+
|
|
9
|
+
NAO invente boas praticas do nada — todo instinct precisa estar fundamentado nos registros deste projeto.
|
|
10
|
+
|
|
11
|
+
## Fontes (somente leitura; NAO ha observador sempre-ligado)
|
|
12
|
+
Colete sinais apenas do que ja esta persistido:
|
|
13
|
+
1. `.dw/spec/*/MEMORY.md` — decisoes duraveis, especialmente as marcadas com `[confidence: …]` (veja a skill `dw-memory`).
|
|
14
|
+
2. `.dw/bugfixes/*/SUMMARY.md` — causas-raiz recorrentes e os guards adicionados.
|
|
15
|
+
3. `.dw/spec/*/deviations.md` — onde o plano encontrou a realidade.
|
|
16
|
+
4. Historico git recente — `git log --oneline -50` e padroes de mensagem de commit.
|
|
17
|
+
5. `.dw/memory/instincts/*.md` existentes — para ATUALIZAR confianca, nao duplicar.
|
|
18
|
+
|
|
19
|
+
## Processo
|
|
20
|
+
1. **Clusterize** sinais repetidos em candidatos a instinct. Um candidato precisa de **≥2 confirmacoes independentes** (duas tasks, uma decisao + um bugfix, um padrao de commit repetido). Um caso unico NAO e instinct.
|
|
21
|
+
2. **Pontue** a confianca de cada candidato (0.3–0.9) pela regra de confianca do `dw-memory`; nomeie a evidencia.
|
|
22
|
+
3. **Classifique** `domain` (code-style / testing / error-handling / git / workflow / security) e `scope` (project por padrao).
|
|
23
|
+
4. **Apresente** os candidatos no chat como lista markdown — id, trigger, action, confidence, evidence. NAO escreva ainda.
|
|
24
|
+
5. **Pergunte**: "Aprovar quais para armazenar? (ids, ou 'todos', ou 'nenhum'). Algum para promover a principio de constitution?"
|
|
25
|
+
6. Na aprovacao:
|
|
26
|
+
- Grave cada instinct aprovado em `.dw/memory/instincts/<slug>.md` no formato de `.agents/skills/dw-memory/references/instincts.md` (crie ou atualize; nunca duplique um id existente).
|
|
27
|
+
- Para os que o usuario escolher promover, encaminhe ao fluxo de constitution — proponha um principio `P-NNN` em `severity: info` para o Step 8 do `/dw-analyze-project`. NAO edite `.dw/constitution.md` direto sem o usuario reconfirmar.
|
|
28
|
+
7. Atualize a confianca de instincts existentes que a nova evidencia reconfirme ou contradiga.
|
|
29
|
+
|
|
30
|
+
## Regras
|
|
31
|
+
- Nunca escreva um instinct ou mudanca de constitution sem aprovacao explicita (espelha o tratamento de constitution + STATE).
|
|
32
|
+
- Fundamente todo instinct em evidencia citada; descarte candidatos que nao consiga fundamentar em ≥2 confirmacoes.
|
|
33
|
+
- Mantenha instincts atomicos — um trigger, uma action. Divida aprendizados compostos.
|
|
34
|
+
- Scope `project` por padrao; marque `global` so quando o padrao aparece entre projetos.
|
|
35
|
+
- Este comando le e propoe; NUNCA modifica codigo-fonte.
|
|
36
|
+
|
|
37
|
+
## Saida
|
|
38
|
+
Uma lista de instincts propostos/atualizados (id, trigger, action, confidence, evidence); depois, apos aprovacao, os arquivos gravados em `.dw/memory/instincts/` e quaisquer propostas de constitution encaminhadas.
|
|
39
|
+
|
|
40
|
+
Marcador final: `## LEARN COMPLETE`
|
|
41
|
+
</system_instructions>
|
|
@@ -70,6 +70,8 @@ A ferramenta e obrigatoria no planejamento porque preserva escolhas explicitas d
|
|
|
70
70
|
|
|
71
71
|
Se `.dw/intel/` não existir, caia para `.dw/rules/` e grep direto. Sugira `/dw-intel --build` para popular o intel.
|
|
72
72
|
|
|
73
|
+
Se `.dw/memory/instincts/` tiver entradas, carregue as de confidence ≥0.7 cujo `trigger` case com a feature (lazy, só por trigger) — codificam convenções aprendidas pelo `/dw-learn` que valem respeitar no spec.
|
|
74
|
+
|
|
73
75
|
## Estágio 1 — Geração de PRD
|
|
74
76
|
|
|
75
77
|
Roda em modo padrão OU `plan prd`.
|
|
@@ -139,6 +139,7 @@ Se FALTANDO > 0, o veredicto sugere revisitar `/dw-plan tasks` pra escopar ou `/
|
|
|
139
139
|
- Padrões gerais: sem `any` em TS, sem `console.log` em prod, error handling, multi-tenancy.
|
|
140
140
|
- Backend patterns de `.dw/rules/<backend>.md`: Clean Architecture, use-case return types, DTOs, queries parametrizadas.
|
|
141
141
|
- Frontend patterns de `.dw/rules/<frontend>.md`: Server Components default, forms patterns, design system.
|
|
142
|
+
- Baseline curada: verifique o diff contra a `.dw/rules-library/<stack>.md` (+ `common.md`) da stack ativa como régua declarativa. As `.dw/rules/` do projeto e a `.dw/constitution.md` sobrepõem onde diferirem.
|
|
142
143
|
|
|
143
144
|
3. **Constitution compliance** (contra `.dw/constitution.md`):
|
|
144
145
|
- Para cada princípio, checar diff por violações conforme linha Enforcement do princípio.
|
|
@@ -31,6 +31,7 @@ Quando disponíveis em `./.agents/skills/`, estas skills são invocadas por task
|
|
|
31
31
|
|
|
32
32
|
- `dw-verify`: **SEMPRE** — antes do commit de cada task, produz Verification Report (test + lint + build GREEN). Sem PASS, sem commit. Iron Law de verificação.
|
|
33
33
|
- `dw-memory`: **SEMPRE** — lê workflow memory no início; atualiza no fim com promotion test (lições que valem pra próxima task são promovidas pra MEMORY.md compartilhada).
|
|
34
|
+
- Instincts (lazy): no início da task, carregue também qualquer instinct de alta confiança (`.dw/memory/instincts/`, confidence ≥0.7) cujo `trigger` case com a task — convenções aprendidas promovidas pelo `/dw-learn`. Case por trigger; nunca carregue o conjunto inteiro.
|
|
34
35
|
- `dw-execute-phase`: fornece agentes `plan-checker` (verificação goal-backward em 6 dimensões antes do código ser tocado) e `executor` (commit atômico + deviation handling).
|
|
35
36
|
- `dw-testing-discipline`: aplica placement doctrine, 6 agent guardrails e 25 anti-patterns ao adicionar testes.
|
|
36
37
|
- `dw-ui-discipline`: quando task toca UI, as 4 grounding questions precisam ser respondidas antes de qualquer decisão visual.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Rules library — curated declarative baseline
|
|
2
|
+
|
|
3
|
+
Curated "what good code SHOULD look like" per stack, installed to `.dw/rules-library/`. This is the third
|
|
4
|
+
leg of the rules model:
|
|
5
|
+
|
|
6
|
+
| Source | Type | Answers | Authored by |
|
|
7
|
+
|---|---|---|---|
|
|
8
|
+
| `.dw/rules-library/` | Curated baseline (this) | what good code looks like in `<stack>` | dev-workflow (shipped) |
|
|
9
|
+
| `.dw/rules/` | Analytical | what THIS code **is** (observed patterns) | `/dw-analyze-project` |
|
|
10
|
+
| `.dw/constitution.md` | Declarative, committed | what THIS project **commits to** | `/dw-analyze-project` (Step 8) |
|
|
11
|
+
|
|
12
|
+
## Precedence
|
|
13
|
+
|
|
14
|
+
A language file overrides `common` where idioms differ. The project's own `.dw/rules/` and
|
|
15
|
+
`.dw/constitution.md` override the library — they describe THIS project; the library is only the default a
|
|
16
|
+
project starts from.
|
|
17
|
+
|
|
18
|
+
## Loading (lazy — protect the context budget)
|
|
19
|
+
|
|
20
|
+
Commands load ONLY the files for the **active stack**, resolved via `.dw/config/stack-mappings.json`
|
|
21
|
+
(`common.md` + `<stack>.md`). Never load the whole library. `/dw-analyze-project` uses it to seed
|
|
22
|
+
constitution proposals; `/dw-review` reads the active stack's baseline as the declarative bar.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Baseline rules — common (all languages)
|
|
2
|
+
|
|
3
|
+
Declarative baseline: what code SHOULD be, regardless of stack. Language files override or specialize these
|
|
4
|
+
where idioms differ. Complements `.dw/rules/` (observed) and `.dw/constitution.md` (committed).
|
|
5
|
+
|
|
6
|
+
## Code style
|
|
7
|
+
- Prefer immutability: return new values, don't mutate inputs. Mutate only in a measured hot path.
|
|
8
|
+
- Name for intent: `overdueInvoices`, not `data`/`tmp`/`x`. A name that needs a comment is the wrong name.
|
|
9
|
+
- Keep functions small and single-purpose; extract when a block needs its own comment to be understood.
|
|
10
|
+
- No magic values: name constants (except self-evident ones like HTTP codes or `0`/`-1` indexes).
|
|
11
|
+
|
|
12
|
+
## Error handling
|
|
13
|
+
- Never swallow errors. Handle, propagate, or log with context — never an empty catch (see `dw-silent-failure`).
|
|
14
|
+
- Validate untrusted input once, where it enters the system; fail loudly at boundaries.
|
|
15
|
+
- Timeout on every network/IO call; rollback partial transactional work.
|
|
16
|
+
|
|
17
|
+
## Testing
|
|
18
|
+
- Test behavior, not implementation. A test that breaks on a rename tested the wrong thing.
|
|
19
|
+
- Cover error and edge paths (empty, null, boundary, failure), not just the happy path.
|
|
20
|
+
- New bug → regression test first, then fix (see `dw-testing-discipline`).
|
|
21
|
+
|
|
22
|
+
## Security
|
|
23
|
+
- No secrets in code or logs. Read from env/secret store; `.env` is gitignored.
|
|
24
|
+
- Validate input at the boundary; encode output at the boundary.
|
|
25
|
+
- Least privilege for every credential, token, and role.
|
|
26
|
+
|
|
27
|
+
## Git
|
|
28
|
+
- One intent per commit; Conventional Commits subject (see `dw-git-discipline`).
|
|
29
|
+
- Never force-push shared history; rebase only local branches.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Baseline rules — C# / .NET (extends common)
|
|
2
|
+
|
|
3
|
+
## Style
|
|
4
|
+
- Nullable reference types enabled; warnings as errors. `record`/`readonly` for value types.
|
|
5
|
+
- `async`/`await` end-to-end; never `.Result`/`.Wait()` (deadlocks). Thread `CancellationToken` through.
|
|
6
|
+
- `using` declarations for `IDisposable`; dependency injection over `new` for services.
|
|
7
|
+
|
|
8
|
+
## Errors
|
|
9
|
+
- Catch specific exceptions; never empty catch. Don't use exceptions for normal control flow.
|
|
10
|
+
- Validate arguments at public boundaries (`ArgumentNullException.ThrowIfNull`).
|
|
11
|
+
|
|
12
|
+
## Testing
|
|
13
|
+
- xUnit/NUnit; test public behavior. Mock owned boundaries, not the system under test itself.
|
|
14
|
+
- Arrange-Act-Assert; one behavior per test.
|
|
15
|
+
|
|
16
|
+
## Security
|
|
17
|
+
- Parameterized queries / EF Core — never concatenate SQL. Validate/encode at boundaries.
|
|
18
|
+
- Secrets via configuration / user-secrets / Key Vault, never in source.
|