@brunosps00/dev-workflow 1.3.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/marketplace.json +13 -0
- package/.claude-plugin/plugin.json +31 -0
- package/README.md +24 -4
- package/lib/build-plugin.js +79 -0
- package/lib/constants.js +19 -14
- package/lib/doctor.js +33 -0
- package/lib/hooks.js +179 -0
- package/lib/init.js +68 -0
- package/lib/skill-registry.js +13 -0
- package/lib/uninstall.js +22 -3
- package/lib/validate.js +62 -0
- package/lib/wrappers.js +1 -1
- package/package.json +6 -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 +3 -0
- package/scaffold/en/commands/dw-review.md +2 -0
- package/scaffold/en/commands/dw-run.md +2 -0
- package/scaffold/en/commands/dw-update.md +4 -1
- 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 +3 -0
- package/scaffold/pt-br/commands/dw-review.md +2 -0
- package/scaffold/pt-br/commands/dw-run.md +2 -0
- package/scaffold/pt-br/commands/dw-update.md +4 -1
- 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/git-guardrails.mjs +79 -0
- package/scaffold/scripts/hooks/session-cost.mjs +126 -0
- package/scaffold/scripts/hooks/statusline.mjs +118 -0
- package/scaffold/scripts/lib/model-prices.json +12 -0
- package/scaffold/skill-registry.json +27 -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-minimalism/SKILL.md +98 -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
package/lib/skill-registry.js
CHANGED
|
@@ -9,6 +9,10 @@ const SKILLS_DIR = path.join(SCAFFOLD_DIR, 'skills');
|
|
|
9
9
|
|
|
10
10
|
const VALID_KINDS = new Set(['protocol', 'domain-pack', 'recipe-pack', 'asset-pack']);
|
|
11
11
|
const VALID_LOAD_POLICIES = new Set(['always-small', 'lazy-references', 'opt-in-runtime']);
|
|
12
|
+
// Optional invocation control (mattpocock/skills). Bundled skills live under
|
|
13
|
+
// .agents/skills/ (read by path from command prose), so this is documental for
|
|
14
|
+
// them and feeds the à-la-carte plugin manifest. Default when absent: 'model'.
|
|
15
|
+
const VALID_INVOCATIONS = new Set(['model', 'explicit']);
|
|
12
16
|
const REQUIRED_STRUCTURED_RETURN_FIELDS = [
|
|
13
17
|
'**Status:**',
|
|
14
18
|
'**Scope:**',
|
|
@@ -106,6 +110,15 @@ function validateEntry(entry, issues) {
|
|
|
106
110
|
if (typeof entry.context_limit !== 'number' || entry.context_limit <= 0) {
|
|
107
111
|
issues.push(`Skill registry entry ${entry.name} must set a positive numeric context_limit`);
|
|
108
112
|
}
|
|
113
|
+
|
|
114
|
+
// Optional fields (back-compat: absent is valid; defaults applied by consumers).
|
|
115
|
+
if (entry.invocation !== undefined && !VALID_INVOCATIONS.has(entry.invocation)) {
|
|
116
|
+
issues.push(`Skill registry entry ${entry.name} has invalid invocation: ${entry.invocation}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (entry.exportable !== undefined && typeof entry.exportable !== 'boolean') {
|
|
120
|
+
issues.push(`Skill registry entry ${entry.name} exportable must be a boolean`);
|
|
121
|
+
}
|
|
109
122
|
}
|
|
110
123
|
|
|
111
124
|
function validateSkillStructuredReturn(skillName, skillPath, issues, label = `Skill ${skillName}`) {
|
package/lib/uninstall.js
CHANGED
|
@@ -2,6 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { COMMANDS, PLATFORMS, MCP_SERVERS } = require('./constants');
|
|
4
4
|
const { AGENT_TARGETS, LEGACY_AGENT_TARGETS, readAgentRegistry } = require('./agents');
|
|
5
|
+
const { removeHooks } = require('./hooks');
|
|
5
6
|
|
|
6
7
|
function run() {
|
|
7
8
|
const projectRoot = process.cwd();
|
|
@@ -103,6 +104,23 @@ function run() {
|
|
|
103
104
|
}
|
|
104
105
|
console.log();
|
|
105
106
|
|
|
107
|
+
// 4.5. Remove dev-workflow hooks + statusline from .claude/settings.json
|
|
108
|
+
// (marker-based; user-defined hooks/statusLine are left intact). The hook
|
|
109
|
+
// scripts themselves were removed with .dw/scripts/ above.
|
|
110
|
+
console.log(' Hooks & statusline:');
|
|
111
|
+
try {
|
|
112
|
+
const removedHooks = removeHooks(projectRoot);
|
|
113
|
+
if (removedHooks > 0) {
|
|
114
|
+
console.log(` \x1b[31m-\x1b[0m ${removedHooks} dev-workflow hook/statusline entr${removedHooks === 1 ? 'y' : 'ies'} [removed]`);
|
|
115
|
+
removed += removedHooks;
|
|
116
|
+
} else {
|
|
117
|
+
skipped++;
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
console.log(' Could not parse .claude/settings.json, skipping hook cleanup');
|
|
121
|
+
}
|
|
122
|
+
console.log();
|
|
123
|
+
|
|
106
124
|
// 5. Remove .opencode/package.json
|
|
107
125
|
removeFile(path.join(projectRoot, '.opencode', 'package.json'));
|
|
108
126
|
removeFile(path.join(projectRoot, '.dw', 'install-state.json'));
|
|
@@ -115,9 +133,10 @@ function run() {
|
|
|
115
133
|
console.log(` Done! ${removed} removed, ${skipped} already absent`);
|
|
116
134
|
console.log();
|
|
117
135
|
console.log(' Preserved (user data):');
|
|
118
|
-
console.log(' .dw/rules/
|
|
119
|
-
console.log(' .dw/spec/
|
|
120
|
-
console.log(' .dw/intel/
|
|
136
|
+
console.log(' .dw/rules/ (project rules)');
|
|
137
|
+
console.log(' .dw/spec/ (PRDs and specs)');
|
|
138
|
+
console.log(' .dw/intel/ (codebase index from /dw-intel --build)');
|
|
139
|
+
console.log(' .dw/minimalism.json (dw-minimalism intensity preference)');
|
|
121
140
|
console.log();
|
|
122
141
|
}
|
|
123
142
|
|
package/lib/validate.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { validateSkillRegistry } = require('./skill-registry');
|
|
4
|
+
const { validateAgentRegistry, readAgentRegistry } = require('./agents');
|
|
5
|
+
const { buildManifests } = require('./build-plugin');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Repo quality gate (npm run validate). Validates the skill + agent registries
|
|
9
|
+
* and confirms the committed .claude-plugin/ manifests match what the registry
|
|
10
|
+
* would generate (no drift). Exits non-zero on any issue.
|
|
11
|
+
*/
|
|
12
|
+
function run() {
|
|
13
|
+
const issues = [];
|
|
14
|
+
const warnings = [];
|
|
15
|
+
|
|
16
|
+
const skill = validateSkillRegistry();
|
|
17
|
+
issues.push(...skill.issues);
|
|
18
|
+
warnings.push(...skill.warnings);
|
|
19
|
+
|
|
20
|
+
const agent = validateAgentRegistry(readAgentRegistry());
|
|
21
|
+
issues.push(...agent.issues);
|
|
22
|
+
warnings.push(...agent.warnings);
|
|
23
|
+
|
|
24
|
+
// Plugin manifest drift check.
|
|
25
|
+
const { plugin, marketplace } = buildManifests();
|
|
26
|
+
checkManifestDrift('.claude-plugin/plugin.json', plugin, issues);
|
|
27
|
+
checkManifestDrift('.claude-plugin/marketplace.json', marketplace, issues);
|
|
28
|
+
|
|
29
|
+
console.log('dev-workflow validate\n');
|
|
30
|
+
if (warnings.length) {
|
|
31
|
+
console.log('Warnings:');
|
|
32
|
+
for (const w of warnings) console.log(`- ${w}`);
|
|
33
|
+
console.log();
|
|
34
|
+
}
|
|
35
|
+
if (issues.length) {
|
|
36
|
+
console.log('Issues:');
|
|
37
|
+
for (const i of issues) console.log(`- ${i}`);
|
|
38
|
+
console.log();
|
|
39
|
+
console.log('FAIL');
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
console.log('PASS: skill + agent registries valid; plugin manifests in sync.');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function checkManifestDrift(relPath, expected, issues) {
|
|
46
|
+
const file = path.join(__dirname, '..', relPath);
|
|
47
|
+
if (!fs.existsSync(file)) {
|
|
48
|
+
issues.push(`Missing ${relPath}; run \`npm run build:plugin\`.`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const onDisk = fs.readFileSync(file, 'utf-8');
|
|
52
|
+
const want = JSON.stringify(expected, null, 2) + '\n';
|
|
53
|
+
if (onDisk !== want) {
|
|
54
|
+
issues.push(`${relPath} is out of sync with the registry; run \`npm run build:plugin\`.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = { run };
|
|
59
|
+
|
|
60
|
+
if (require.main === module) {
|
|
61
|
+
run();
|
|
62
|
+
}
|
package/lib/wrappers.js
CHANGED
|
@@ -15,7 +15,7 @@ function generateWrappers(projectRoot, commands, force = false) {
|
|
|
15
15
|
// Directory format: .claude/skills/dw-brainstorm/SKILL.md
|
|
16
16
|
skillFile = path.join(projectRoot, platform.dir, cmd.name, 'SKILL.md');
|
|
17
17
|
}
|
|
18
|
-
const content = platform.wrapperTemplate(cmd.name, cmd.description);
|
|
18
|
+
const content = platform.wrapperTemplate(cmd.name, cmd.description, cmd);
|
|
19
19
|
const status = writeFile(skillFile, content, force);
|
|
20
20
|
results[status]++;
|
|
21
21
|
results.files.push(skillFile);
|
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
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"
|
|
7
7
|
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"validate": "node lib/validate.js",
|
|
10
|
+
"build:plugin": "node lib/build-plugin.js"
|
|
11
|
+
},
|
|
8
12
|
"files": [
|
|
9
13
|
"bin/",
|
|
10
14
|
"lib/",
|
|
11
15
|
"scaffold/",
|
|
16
|
+
".claude-plugin/",
|
|
12
17
|
"README.md",
|
|
13
18
|
"LICENSE"
|
|
14
19
|
],
|
|
@@ -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>
|
|
@@ -39,6 +39,7 @@ When available under `./.agents/skills/`, use these as planning support:
|
|
|
39
39
|
- `dw-council` (opt-in via `--council`): multi-advisor stress-test on the major architectural decision during TechSpec stage.
|
|
40
40
|
- `dw-codebase-intel`: consulted for API conventions, architecture patterns, naming when designing the TechSpec.
|
|
41
41
|
- `dw-search-first`: **REQUIRED** before adding a new dependency, integration, MCP server, reusable helper, or framework-level abstraction.
|
|
42
|
+
- `dw-minimalism`: **REQUIRED** before specifying new modules/services — pressure-tests scope with the YAGNI ladder so the TechSpec doesn't over-build; composes with `dw-search-first`.
|
|
42
43
|
- `dw-context-budget`: use when the plan exceeds 12 tasks, touches 30+ files, or requires loading many docs/skills.
|
|
43
44
|
|
|
44
45
|
## Agent Dispatch
|
|
@@ -69,6 +70,8 @@ The tool is mandatory for planning because it preserves explicit user choices an
|
|
|
69
70
|
|
|
70
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.
|
|
71
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
|
+
|
|
72
75
|
## Stage 1 — PRD generation
|
|
73
76
|
|
|
74
77
|
Runs when default mode OR `plan prd`.
|
|
@@ -47,6 +47,7 @@ When available under `./.agents/skills/`, these are invoked as analytical suppor
|
|
|
47
47
|
- `dw-secure-audit` (**Security Gate**): **ALWAYS for TS/Python/C#/Rust projects** — triggered here and the verdict is enforced. If the project's language is supported and a fresh `.dw/secure-audit/audit-summary.md` is missing OR has REJECTED status, the review verdict is **REJECTED** — no exception. The same gate is also a standalone command (`/dw-secure-audit`) and an explicit phase in `/dw-autopilot`. It now adds Semgrep SAST (diff) + gitleaks secrets on top of OWASP/Trivy/SCA.
|
|
48
48
|
- `security-review`: the OWASP diff-level skill the gate uses (injection, authz, secrets, SSRF, crypto — HIGH CONFIDENCE only).
|
|
49
49
|
- `dw-simplification`: use when the diff touches dense or twisty code — applies Chesterton's Fence, behavior-preserving refactor protocol, complexity metrics.
|
|
50
|
+
- `dw-minimalism`: use when the diff adds code that may be over-built — flags speculative generality, single-caller helpers, premature abstraction, and YAGNI violations (the pre-generation counterpart to `dw-simplification`).
|
|
50
51
|
- `dw-ui-discipline`: use when the diff touches UI — runs the 14 visual-slop patterns + accessibility floor checks. For a deterministic gate, also run `node .dw/scripts/lib/ui-slop-detect.mjs <changed-ui-paths> --fail-on error` (a wrapper over the impeccable detector); treat blocking findings as **REJECTED** and surface warnings in the report.
|
|
51
52
|
- `dw-testing-discipline`: use when the diff touches tests — applies the 25 anti-patterns catalog + 6 agent guardrails (when tests were agent-authored).
|
|
52
53
|
- `dw-llm-eval`: **REQUIRED when the diff touches AI/LLM feature code paths**. Reference dataset + ≥2 oracle rungs + judge calibration (if rung 4 used) + eval run results MUST be in the PR. Missing → REJECTED.
|
|
@@ -138,6 +139,7 @@ If MISSING > 0, the verdict suggests revisiting `/dw-plan tasks` to scope or `/d
|
|
|
138
139
|
- General patterns: no `any` types in TS, no `console.log` in prod, error handling, multi-tenancy.
|
|
139
140
|
- Backend patterns from `.dw/rules/<backend>.md`: Clean Architecture, use-case return types, DTOs, parameterized queries.
|
|
140
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.
|
|
141
143
|
|
|
142
144
|
3. **Constitution compliance** (against `.dw/constitution.md`):
|
|
143
145
|
- For each principle, check diff for violations per the principle's Enforcement line.
|
|
@@ -31,10 +31,12 @@ 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.
|
|
37
38
|
- `dw-llm-eval`: when the task touches AI feature code paths, the reference dataset + oracle ladder rules apply.
|
|
39
|
+
- `dw-minimalism`: **before writing new code** — climb the YAGNI decision ladder (need it? reuse? stdlib? native? installed dep? one line?) at the active intensity, then write the minimum. Hands new dependencies to `dw-search-first`.
|
|
38
40
|
- `vercel-react-best-practices`: when the task touches React/Next.js performance.
|
|
39
41
|
|
|
40
42
|
## Constitution Gate
|
|
@@ -26,6 +26,8 @@ SNAPSHOT_DIR=".dw/.backup/$(date -u +%Y%m%dT%H%M%SZ)"
|
|
|
26
26
|
mkdir -p "$SNAPSHOT_DIR"
|
|
27
27
|
cp -r .dw/commands .dw/templates .dw/references .dw/scripts "$SNAPSHOT_DIR/" 2>/dev/null
|
|
28
28
|
[ -d .agents/skills ] && cp -r .agents/skills "$SNAPSHOT_DIR/agents-skills" 2>/dev/null
|
|
29
|
+
# .claude/settings.json is now mutated by update (MCPs + hooks + statusLine)
|
|
30
|
+
[ -f .claude/settings.json ] && mkdir -p "$SNAPSHOT_DIR/claude" && cp .claude/settings.json "$SNAPSHOT_DIR/claude/settings.json" 2>/dev/null
|
|
29
31
|
echo "Snapshot saved to $SNAPSHOT_DIR"
|
|
30
32
|
```
|
|
31
33
|
|
|
@@ -127,7 +129,7 @@ If invoked with `--rollback`:
|
|
|
127
129
|
1. List snapshots in `.dw/.backup/`
|
|
128
130
|
2. If none exist: STOP and report "No snapshot available"
|
|
129
131
|
3. If more than one exists: ask the user which to restore (default: most recent)
|
|
130
|
-
4. Confirm with the user: "Restore snapshot `<path>`? This OVERWRITES `.dw/commands/`, `.dw/templates/`, `.dw/references/`, `.dw/scripts/`,
|
|
132
|
+
4. Confirm with the user: "Restore snapshot `<path>`? This OVERWRITES `.dw/commands/`, `.dw/templates/`, `.dw/references/`, `.dw/scripts/`, `.agents/skills/`, and `.claude/settings.json`. Proceed? [y/N]"
|
|
131
133
|
5. Only after `y`: copy back
|
|
132
134
|
|
|
133
135
|
```bash
|
|
@@ -136,6 +138,7 @@ cp -r "$SNAPSHOT_DIR/templates" .dw/
|
|
|
136
138
|
cp -r "$SNAPSHOT_DIR/references" .dw/ 2>/dev/null
|
|
137
139
|
cp -r "$SNAPSHOT_DIR/scripts" .dw/ 2>/dev/null
|
|
138
140
|
[ -d "$SNAPSHOT_DIR/agents-skills" ] && cp -r "$SNAPSHOT_DIR/agents-skills" .agents/skills 2>/dev/null
|
|
141
|
+
[ -f "$SNAPSHOT_DIR/claude/settings.json" ] && cp "$SNAPSHOT_DIR/claude/settings.json" .claude/settings.json 2>/dev/null
|
|
139
142
|
```
|
|
140
143
|
|
|
141
144
|
6. Report: snapshot restored, version likely recovered (read from `.dw/commands/dw-help.md` or metadata if present)
|
|
@@ -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>
|
|
@@ -39,6 +39,7 @@ Quando disponíveis em `./.agents/skills/`, use como suporte:
|
|
|
39
39
|
- `dw-council` (opt-in via `--council`): stress-test multi-conselheiro sobre a decisão arquitetural principal no estágio TechSpec.
|
|
40
40
|
- `dw-codebase-intel`: consultado para convenções de API, padrões arquiteturais, naming ao desenhar TechSpec.
|
|
41
41
|
- `dw-search-first`: **OBRIGATÓRIO** antes de adicionar nova dependency, integration, MCP server, helper reutilizavel ou abstracao de framework.
|
|
42
|
+
- `dw-minimalism`: **OBRIGATÓRIO** antes de especificar novos módulos/serviços — pressiona o escopo com o ladder YAGNI pro TechSpec não over-buildar; compõe com `dw-search-first`.
|
|
42
43
|
- `dw-context-budget`: use quando o plano passar de 12 tasks, tocar 30+ arquivos, ou exigir carregar muitos docs/skills.
|
|
43
44
|
|
|
44
45
|
## Agent Dispatch
|
|
@@ -69,6 +70,8 @@ A ferramenta e obrigatoria no planejamento porque preserva escolhas explicitas d
|
|
|
69
70
|
|
|
70
71
|
Se `.dw/intel/` não existir, caia para `.dw/rules/` e grep direto. Sugira `/dw-intel --build` para popular o intel.
|
|
71
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
|
+
|
|
72
75
|
## Estágio 1 — Geração de PRD
|
|
73
76
|
|
|
74
77
|
Roda em modo padrão OU `plan prd`.
|
|
@@ -47,6 +47,7 @@ Quando disponíveis em `./.agents/skills/`, são invocadas como apoio analítico
|
|
|
47
47
|
- `dw-secure-audit` (**Security Gate**): **SEMPRE para projetos TS/Python/C#/Rust** — acionado aqui e o verdict é enforced. Se a linguagem é suportada e `.dw/secure-audit/audit-summary.md` fresco está ausente OU REPROVADO, o verdict do review é **REPROVADO** — sem exceção. O mesmo gate também é comando standalone (`/dw-secure-audit`) e fase explícita no `/dw-autopilot`. Agora soma Semgrep SAST (diff) + gitleaks secrets sobre OWASP/Trivy/SCA.
|
|
48
48
|
- `security-review`: a skill OWASP nível-diff que o gate usa (injection, authz, secrets, SSRF, crypto — só HIGH CONFIDENCE).
|
|
49
49
|
- `dw-simplification`: use quando diff toca código denso — aplica Chesterton's Fence, protocolo de refactor preservando comportamento, métricas de complexidade.
|
|
50
|
+
- `dw-minimalism`: use quando o diff adiciona código que pode estar over-built — flagra generalidade especulativa, helpers de um único caller, abstração prematura e violações de YAGNI (a contraparte pré-geração do `dw-simplification`).
|
|
50
51
|
- `dw-ui-discipline`: use quando diff toca UI — roda os 14 visual-slop patterns + accessibility floor. Para um gate determinístico, rode também `node .dw/scripts/lib/ui-slop-detect.mjs <paths-ui-alterados> --fail-on error` (wrapper sobre o detector do impeccable); trate findings bloqueantes como **REJECTED** e reporte os warnings.
|
|
51
52
|
- `dw-testing-discipline`: use quando diff toca testes — aplica catálogo de 25 anti-patterns + 6 agent guardrails (quando testes foram agent-authored).
|
|
52
53
|
- `dw-llm-eval`: **OBRIGATÓRIO quando diff toca código de feature AI/LLM**. Reference dataset + ≥2 oracle rungs + judge calibration (se rung 4 usado) + eval run results DEVEM estar no PR. Faltando → REPROVADO.
|
|
@@ -138,6 +139,7 @@ Se FALTANDO > 0, o veredicto sugere revisitar `/dw-plan tasks` pra escopar ou `/
|
|
|
138
139
|
- Padrões gerais: sem `any` em TS, sem `console.log` em prod, error handling, multi-tenancy.
|
|
139
140
|
- Backend patterns de `.dw/rules/<backend>.md`: Clean Architecture, use-case return types, DTOs, queries parametrizadas.
|
|
140
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.
|
|
141
143
|
|
|
142
144
|
3. **Constitution compliance** (contra `.dw/constitution.md`):
|
|
143
145
|
- Para cada princípio, checar diff por violações conforme linha Enforcement do princípio.
|
|
@@ -31,10 +31,12 @@ 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.
|
|
37
38
|
- `dw-llm-eval`: quando task toca código de feature AI, regras de reference dataset + oracle ladder se aplicam.
|
|
39
|
+
- `dw-minimalism`: **antes de escrever código novo** — sobe o decision ladder YAGNI (precisa existir? reusar? stdlib? nativo? dep instalada? uma linha?) na intensidade ativa, depois escreve o mínimo. Passa novas dependências pro `dw-search-first`.
|
|
38
40
|
- `vercel-react-best-practices`: quando task toca performance React/Next.js.
|
|
39
41
|
|
|
40
42
|
## Constitution Gate
|
|
@@ -27,6 +27,8 @@ mkdir -p "$SNAPSHOT_DIR"
|
|
|
27
27
|
cp -r .dw/commands .dw/templates .dw/references .dw/scripts "$SNAPSHOT_DIR/" 2>/dev/null
|
|
28
28
|
# agents/skills (bundled) tambem fazem parte do update
|
|
29
29
|
[ -d .agents/skills ] && cp -r .agents/skills "$SNAPSHOT_DIR/agents-skills" 2>/dev/null
|
|
30
|
+
# .claude/settings.json agora e mutado pelo update (MCPs + hooks + statusLine)
|
|
31
|
+
[ -f .claude/settings.json ] && mkdir -p "$SNAPSHOT_DIR/claude" && cp .claude/settings.json "$SNAPSHOT_DIR/claude/settings.json" 2>/dev/null
|
|
30
32
|
echo "Snapshot salvo em $SNAPSHOT_DIR"
|
|
31
33
|
```
|
|
32
34
|
|
|
@@ -128,7 +130,7 @@ Se invocado com `--rollback`:
|
|
|
128
130
|
1. Listar snapshots em `.dw/.backup/`
|
|
129
131
|
2. Se nenhum existir: PARAR e reportar "Nenhum snapshot disponível"
|
|
130
132
|
3. Se mais de um existir: perguntar ao usuário qual restaurar (padrão: mais recente)
|
|
131
|
-
4. Confirmar com o usuário: "Restaurar snapshot `<path>`? Isso SOBRESCREVE `.dw/commands/`, `.dw/templates/`, `.dw/references/`, `.dw/scripts/` e `.
|
|
133
|
+
4. Confirmar com o usuário: "Restaurar snapshot `<path>`? Isso SOBRESCREVE `.dw/commands/`, `.dw/templates/`, `.dw/references/`, `.dw/scripts/`, `.agents/skills/` e `.claude/settings.json`. Prosseguir? [s/N]"
|
|
132
134
|
5. Somente após `s`: copiar de volta
|
|
133
135
|
|
|
134
136
|
```bash
|
|
@@ -137,6 +139,7 @@ cp -r "$SNAPSHOT_DIR/templates" .dw/
|
|
|
137
139
|
cp -r "$SNAPSHOT_DIR/references" .dw/ 2>/dev/null
|
|
138
140
|
cp -r "$SNAPSHOT_DIR/scripts" .dw/ 2>/dev/null
|
|
139
141
|
[ -d "$SNAPSHOT_DIR/agents-skills" ] && cp -r "$SNAPSHOT_DIR/agents-skills" .agents/skills 2>/dev/null
|
|
142
|
+
[ -f "$SNAPSHOT_DIR/claude/settings.json" ] && cp "$SNAPSHOT_DIR/claude/settings.json" .claude/settings.json 2>/dev/null
|
|
140
143
|
```
|
|
141
144
|
|
|
142
145
|
6. Reportar: snapshot restaurado, versão provavelmente recuperada (ler de `.dw/commands/dw-help.md` ou metadata se houver)
|
|
@@ -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.
|