@applica-software-guru/sdd-core 0.1.0 → 1.0.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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parser/bug-parser.d.ts +8 -0
- package/dist/parser/bug-parser.d.ts.map +1 -0
- package/dist/parser/bug-parser.js +45 -0
- package/dist/parser/bug-parser.js.map +1 -0
- package/dist/scaffold/init.js +1 -1
- package/dist/scaffold/init.js.map +1 -1
- package/dist/scaffold/templates.d.ts +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +55 -9
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/sdd.d.ts +4 -1
- package/dist/sdd.d.ts.map +1 -1
- package/dist/sdd.js +26 -0
- package/dist/sdd.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/index.ts +3 -0
- package/src/parser/bug-parser.ts +41 -0
- package/src/scaffold/init.ts +1 -1
- package/src/scaffold/templates.ts +55 -9
- package/src/sdd.ts +31 -1
- package/src/types.ts +15 -0
- package/tests/bug.test.ts +173 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { SDD } from './sdd.js';
|
|
2
|
-
export type { StoryFrontmatter, StoryFile, PendingItem, Delta, DeltaFile, ValidationResult, ValidationIssue, StoryStatus, StoryFileStatus, SDDConfig, ChangeRequest, ChangeRequestFrontmatter, ChangeRequestStatus, } from './types.js';
|
|
2
|
+
export type { StoryFrontmatter, StoryFile, PendingItem, Delta, DeltaFile, ValidationResult, ValidationIssue, StoryStatus, StoryFileStatus, SDDConfig, ChangeRequest, ChangeRequestFrontmatter, ChangeRequestStatus, Bug, BugFrontmatter, BugStatus, } from './types.js';
|
|
3
3
|
export { SDDError, LockFileNotFoundError, ParseError, ProjectNotInitializedError } from './errors.js';
|
|
4
4
|
export type { ProjectInfo } from './scaffold/templates.js';
|
|
5
5
|
export { isSDDProject, readConfig } from './config/config-manager.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,EACb,wBAAwB,EACxB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,EACb,wBAAwB,EACxB,mBAAmB,EACnB,GAAG,EACH,cAAc,EACd,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACtG,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAAtB,6FAAA,GAAG,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAAtB,6FAAA,GAAG,OAAA;AAmBZ,yCAAsG;AAA7F,qGAAA,QAAQ,OAAA;AAAE,kHAAA,qBAAqB,OAAA;AAAE,uGAAA,UAAU,OAAA;AAAE,uHAAA,0BAA0B,OAAA;AAEhF,gEAAsE;AAA7D,iHAAA,YAAY,OAAA;AAAE,+GAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Bug, BugFrontmatter } from '../types.js';
|
|
2
|
+
export declare function discoverBugFiles(root: string): Promise<string[]>;
|
|
3
|
+
export declare function parseBugFile(filePath: string, content: string): {
|
|
4
|
+
frontmatter: BugFrontmatter;
|
|
5
|
+
body: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function parseAllBugFiles(root: string): Promise<Bug[]>;
|
|
8
|
+
//# sourceMappingURL=bug-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bug-parser.d.ts","sourceRoot":"","sources":["../../src/parser/bug-parser.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGvD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAItE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAa7G;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAYnE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.discoverBugFiles = discoverBugFiles;
|
|
7
|
+
exports.parseBugFile = parseBugFile;
|
|
8
|
+
exports.parseAllBugFiles = parseAllBugFiles;
|
|
9
|
+
const promises_1 = require("node:fs/promises");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const glob_1 = require("glob");
|
|
12
|
+
const gray_matter_1 = __importDefault(require("gray-matter"));
|
|
13
|
+
const errors_js_1 = require("../errors.js");
|
|
14
|
+
async function discoverBugFiles(root) {
|
|
15
|
+
const pattern = 'bugs/*.md';
|
|
16
|
+
const matches = await (0, glob_1.glob)(pattern, { cwd: root, absolute: true });
|
|
17
|
+
return matches.sort();
|
|
18
|
+
}
|
|
19
|
+
function parseBugFile(filePath, content) {
|
|
20
|
+
try {
|
|
21
|
+
const { data, content: body } = (0, gray_matter_1.default)(content);
|
|
22
|
+
const frontmatter = {
|
|
23
|
+
title: data.title ?? '',
|
|
24
|
+
status: data.status ?? 'open',
|
|
25
|
+
author: data.author ?? '',
|
|
26
|
+
'created-at': data['created-at'] ?? '',
|
|
27
|
+
};
|
|
28
|
+
return { frontmatter, body };
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
throw new errors_js_1.ParseError(filePath, err.message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function parseAllBugFiles(root) {
|
|
35
|
+
const paths = await discoverBugFiles(root);
|
|
36
|
+
const results = [];
|
|
37
|
+
for (const absPath of paths) {
|
|
38
|
+
const content = await (0, promises_1.readFile)(absPath, 'utf-8');
|
|
39
|
+
const relPath = (0, node_path_1.relative)(root, absPath);
|
|
40
|
+
const { frontmatter, body } = parseBugFile(relPath, content);
|
|
41
|
+
results.push({ relativePath: relPath, frontmatter, body });
|
|
42
|
+
}
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=bug-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bug-parser.js","sourceRoot":"","sources":["../../src/parser/bug-parser.ts"],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CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,IAAA,oBAAQ,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/scaffold/init.js
CHANGED
|
@@ -26,7 +26,7 @@ async function initProject(root, info) {
|
|
|
26
26
|
await (0, config_manager_js_1.writeConfig)(root, config);
|
|
27
27
|
createdFiles.push('.sdd/config.yaml');
|
|
28
28
|
// Create directory structure
|
|
29
|
-
const dirs = ['product', 'product/features', 'system', 'code', 'change-requests'];
|
|
29
|
+
const dirs = ['product', 'product/features', 'system', 'code', 'change-requests', 'bugs'];
|
|
30
30
|
for (const dir of dirs) {
|
|
31
31
|
const absDir = (0, node_path_1.resolve)(root, dir);
|
|
32
32
|
if (!(0, node_fs_1.existsSync)(absDir)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/scaffold/init.ts"],"names":[],"mappings":";;AAQA,kCA8DC;AAtED,+CAAoD;AACpD,qCAAqC;AACrC,yCAAoC;AACpC,iDAAqE;AACrE,mEAAsE;AACtE,0CAAmD;AAG5C,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,IAAkB;IAChE,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,IAAA,8BAAU,EAAC,IAAI,CAAC,CAAC;IAEhC,kBAAkB;IAClB,IAAI,CAAC,IAAA,kBAAS,EAAC,IAAI,CAAC,EAAE,CAAC;QACrB,IAAA,gBAAO,EAAC,IAAI,CAAC,CAAC;QACd,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,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EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,IAAA,oBAAU,EAAC,OAAO,CAAC;YAAE,SAAS;QAElC,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,IAAA,oBAAU,EAAC,MAAM,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAA,gBAAK,EAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,MAAM,IAAA,oBAAS,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3C,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface ProjectInfo {
|
|
2
2
|
description: string;
|
|
3
3
|
}
|
|
4
|
-
export declare const AGENT_MD_TEMPLATE = "# SDD Project\n\nThis project uses **Story Driven Development (SDD)**.\nDocumentation drives implementation: read the docs first, then write code.\n\n## Workflow\n\n1. Run `sdd cr pending` \u2014 check if there are change requests to process
|
|
4
|
+
export declare const AGENT_MD_TEMPLATE = "# SDD Project\n\nThis project uses **Story Driven Development (SDD)**.\nDocumentation drives implementation: read the docs first, then write code.\n\n## Workflow\n\n1. Run `sdd bug open` \u2014 check if there are open bugs to fix first\n2. If there are open bugs, fix the code/docs, then run `sdd mark-bug-resolved`\n3. Run `sdd cr pending` \u2014 check if there are change requests to process\n4. If there are pending CRs, apply them to the docs, then run `sdd mark-cr-applied`\n5. Run `sdd sync` to see what needs to be implemented\n6. Read the documentation files listed in the sync output\n7. Implement what each file describes, writing code inside `code/`\n8. After implementing, mark files as synced:\n\n```\nsdd mark-synced product/features/auth.md\n```\n\nOr mark all pending files at once:\n\n```\nsdd mark-synced\n```\n\n9. **Commit immediately after mark-synced** \u2014 this is mandatory:\n\n```\ngit add -A && git commit -m \"sdd sync: <brief description of what was implemented>\"\n```\n\nDo NOT skip this step. Every mark-synced must be followed by a git commit.\n\n### Removing a feature\n\nIf a documentation file has `status: deleted`, it means that feature should be removed.\nDelete the related code in `code/`, then run `sdd mark-synced <file>` (the doc file will be removed automatically), then commit.\n\n## Available commands\n\n- `sdd status` \u2014 See all documentation files and their state (new/changed/deleted/synced)\n- `sdd diff` \u2014 See what changed since last sync\n- `sdd sync` \u2014 Get the sync prompt for pending files (includes git diff for changed files)\n- `sdd validate` \u2014 Check for broken references and issues\n- `sdd mark-synced [files...]` \u2014 Mark specific files (or all) as synced\n- `sdd cr list` \u2014 List all change requests with their status\n- `sdd cr pending` \u2014 Show draft change requests to process\n- `sdd mark-cr-applied [files...]` \u2014 Mark change requests as applied\n- `sdd bug list` \u2014 List all bugs with their status\n- `sdd bug open` \u2014 Show open bugs to fix\n- `sdd mark-bug-resolved [files...]` \u2014 Mark bugs as resolved\n\n## Rules\n\n1. **Always commit after mark-synced** \u2014 run `git add -A && git commit -m \"sdd sync: ...\"` immediately after `sdd mark-synced`. Never leave synced files uncommitted.\n2. Before running `sdd sync`, check for open bugs with `sdd bug open` and pending change requests with `sdd cr pending`\n3. If there are pending CRs, apply them to the docs first, then mark them with `sdd mark-cr-applied`\n4. Only implement what the sync prompt asks for\n5. All generated code goes inside `code/`\n6. Respect all constraints in `## Agent Notes` sections (if present)\n7. Do not edit files inside `.sdd/` manually\n\n## File format\n\nEvery `.md` file in `product/` and `system/` must start with this YAML frontmatter:\n\n```yaml\n---\ntitle: \"File title\"\nstatus: new\nauthor: \"\"\nlast-modified: \"2025-01-01T00:00:00.000Z\"\nversion: \"1.0\"\n---\n```\n\n- **status**: one of:\n - `new` \u2014 new file, needs to be implemented\n - `changed` \u2014 modified since last sync, code needs updating\n - `deleted` \u2014 feature to be removed, agent should delete related code\n - `synced` \u2014 already implemented, up to date\n- **version**: patch-bump on each edit (1.0 \u2192 1.1 \u2192 1.2)\n- **last-modified**: ISO 8601 datetime, updated on each edit\n\n## How sync works\n\n`sdd sync` generates a structured prompt for the agent based on pending files:\n\n- **`new` files**: the agent reads the full documentation and implements it from scratch\n- **`changed` files**: SDD uses `git diff` to compute what changed in the documentation since the last commit, and includes the diff in the sync prompt \u2014 this way the agent sees exactly what was modified and can update only the affected code\n- **`deleted` files**: the agent removes the related code\n\nThis is why **committing after every mark-synced is mandatory** \u2014 the git history is what SDD uses to detect changes.\n\n## Change Requests\n\nChange Requests (CRs) are markdown files in `change-requests/` that describe modifications to the documentation.\n\n### CR format\n\n```yaml\n---\ntitle: \"Add authentication feature\"\nstatus: draft\nauthor: \"user\"\ncreated-at: \"2025-01-01T00:00:00.000Z\"\n---\n```\n\n- **status**: `draft` (pending) or `applied` (already processed)\n\n### CR workflow\n\n1. Check for pending CRs: `sdd cr pending`\n2. Read each pending CR and apply the described changes to the documentation files (marking them as `new`, `changed`, or `deleted`)\n3. After applying a CR to the docs, mark it: `sdd mark-cr-applied change-requests/CR-001.md`\n4. Then run `sdd sync` to implement the code changes\n\n### CR commands\n\n- `sdd cr list` \u2014 See all change requests and their status\n- `sdd cr pending` \u2014 Show only draft CRs to process\n- `sdd mark-cr-applied [files...]` \u2014 Mark CRs as applied after updating the docs\n\n## Bugs\n\nBugs are markdown files in `bugs/` that describe problems found in the codebase.\n\n### Bug format\n\n```yaml\n---\ntitle: \"Login fails with empty password\"\nstatus: open\nauthor: \"user\"\ncreated-at: \"2025-01-01T00:00:00.000Z\"\n---\n```\n\n- **status**: `open` (needs fixing) or `resolved` (already fixed)\n\n### Bug workflow\n\n1. Check for open bugs: `sdd bug open`\n2. Read each open bug and fix the code and/or documentation\n3. After fixing a bug, mark it: `sdd mark-bug-resolved bugs/BUG-001.md`\n4. Commit the fix\n\n### Bug commands\n\n- `sdd bug list` \u2014 See all bugs and their status\n- `sdd bug open` \u2014 Show only open bugs to fix\n- `sdd mark-bug-resolved [files...]` \u2014 Mark bugs as resolved after fixing\n\n## UX and screenshots\n\nWhen a feature has UX mockups or screenshots, place them next to the feature doc:\n\n- **Simple feature** (no screenshots): `product/features/auth.md`\n- **Feature with screenshots**: use a folder with `index.md`:\n\n```\nproduct/features/auth/\n index.md \u2190 feature doc\n login.png \u2190 screenshot\n register.png \u2190 screenshot\n```\n\nReference images in the markdown with relative paths:\n\n```markdown\n## UX\n\n\n\n```\n\nBoth formats work \u2014 use a folder only when you have screenshots or multiple files for a feature.\n\n## Project structure\n\n- `product/` \u2014 What to build (vision, users, features)\n- `system/` \u2014 How to build it (entities, architecture, tech stack, interfaces)\n- `code/` \u2014 All generated source code goes here\n- `change-requests/` \u2014 Change requests to the documentation\n- `bugs/` \u2014 Bug reports\n- `.sdd/` \u2014 Project config and sync state (do not edit)\n";
|
|
5
5
|
export declare const EMPTY_LOCK_TEMPLATE: () => string;
|
|
6
6
|
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/scaffold/templates.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/scaffold/templates.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,ylNA4L7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,cAE/B,CAAC"}
|
|
@@ -21,12 +21,14 @@ Documentation drives implementation: read the docs first, then write code.
|
|
|
21
21
|
|
|
22
22
|
## Workflow
|
|
23
23
|
|
|
24
|
-
1. Run \`sdd
|
|
25
|
-
2. If there are
|
|
26
|
-
3. Run \`sdd
|
|
27
|
-
4.
|
|
28
|
-
5.
|
|
29
|
-
6.
|
|
24
|
+
1. Run \`sdd bug open\` — check if there are open bugs to fix first
|
|
25
|
+
2. If there are open bugs, fix the code/docs, then run \`sdd mark-bug-resolved\`
|
|
26
|
+
3. Run \`sdd cr pending\` — check if there are change requests to process
|
|
27
|
+
4. If there are pending CRs, apply them to the docs, then run \`sdd mark-cr-applied\`
|
|
28
|
+
5. Run \`sdd sync\` to see what needs to be implemented
|
|
29
|
+
6. Read the documentation files listed in the sync output
|
|
30
|
+
7. Implement what each file describes, writing code inside \`code/\`
|
|
31
|
+
8. After implementing, mark files as synced:
|
|
30
32
|
|
|
31
33
|
\`\`\`
|
|
32
34
|
sdd mark-synced product/features/auth.md
|
|
@@ -38,7 +40,7 @@ Or mark all pending files at once:
|
|
|
38
40
|
sdd mark-synced
|
|
39
41
|
\`\`\`
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
9. **Commit immediately after mark-synced** — this is mandatory:
|
|
42
44
|
|
|
43
45
|
\`\`\`
|
|
44
46
|
git add -A && git commit -m "sdd sync: <brief description of what was implemented>"
|
|
@@ -55,17 +57,20 @@ Delete the related code in \`code/\`, then run \`sdd mark-synced <file>\` (the d
|
|
|
55
57
|
|
|
56
58
|
- \`sdd status\` — See all documentation files and their state (new/changed/deleted/synced)
|
|
57
59
|
- \`sdd diff\` — See what changed since last sync
|
|
58
|
-
- \`sdd sync\` — Get the sync prompt for pending files (
|
|
60
|
+
- \`sdd sync\` — Get the sync prompt for pending files (includes git diff for changed files)
|
|
59
61
|
- \`sdd validate\` — Check for broken references and issues
|
|
60
62
|
- \`sdd mark-synced [files...]\` — Mark specific files (or all) as synced
|
|
61
63
|
- \`sdd cr list\` — List all change requests with their status
|
|
62
64
|
- \`sdd cr pending\` — Show draft change requests to process
|
|
63
65
|
- \`sdd mark-cr-applied [files...]\` — Mark change requests as applied
|
|
66
|
+
- \`sdd bug list\` — List all bugs with their status
|
|
67
|
+
- \`sdd bug open\` — Show open bugs to fix
|
|
68
|
+
- \`sdd mark-bug-resolved [files...]\` — Mark bugs as resolved
|
|
64
69
|
|
|
65
70
|
## Rules
|
|
66
71
|
|
|
67
72
|
1. **Always commit after mark-synced** — run \`git add -A && git commit -m "sdd sync: ..."\` immediately after \`sdd mark-synced\`. Never leave synced files uncommitted.
|
|
68
|
-
2. Before running \`sdd sync\`, check for pending change requests with \`sdd cr pending\`
|
|
73
|
+
2. Before running \`sdd sync\`, check for open bugs with \`sdd bug open\` and pending change requests with \`sdd cr pending\`
|
|
69
74
|
3. If there are pending CRs, apply them to the docs first, then mark them with \`sdd mark-cr-applied\`
|
|
70
75
|
4. Only implement what the sync prompt asks for
|
|
71
76
|
5. All generated code goes inside \`code/\`
|
|
@@ -94,6 +99,16 @@ version: "1.0"
|
|
|
94
99
|
- **version**: patch-bump on each edit (1.0 → 1.1 → 1.2)
|
|
95
100
|
- **last-modified**: ISO 8601 datetime, updated on each edit
|
|
96
101
|
|
|
102
|
+
## How sync works
|
|
103
|
+
|
|
104
|
+
\`sdd sync\` generates a structured prompt for the agent based on pending files:
|
|
105
|
+
|
|
106
|
+
- **\`new\` files**: the agent reads the full documentation and implements it from scratch
|
|
107
|
+
- **\`changed\` files**: SDD uses \`git diff\` to compute what changed in the documentation since the last commit, and includes the diff in the sync prompt — this way the agent sees exactly what was modified and can update only the affected code
|
|
108
|
+
- **\`deleted\` files**: the agent removes the related code
|
|
109
|
+
|
|
110
|
+
This is why **committing after every mark-synced is mandatory** — the git history is what SDD uses to detect changes.
|
|
111
|
+
|
|
97
112
|
## Change Requests
|
|
98
113
|
|
|
99
114
|
Change Requests (CRs) are markdown files in \`change-requests/\` that describe modifications to the documentation.
|
|
@@ -124,6 +139,36 @@ created-at: "2025-01-01T00:00:00.000Z"
|
|
|
124
139
|
- \`sdd cr pending\` — Show only draft CRs to process
|
|
125
140
|
- \`sdd mark-cr-applied [files...]\` — Mark CRs as applied after updating the docs
|
|
126
141
|
|
|
142
|
+
## Bugs
|
|
143
|
+
|
|
144
|
+
Bugs are markdown files in \`bugs/\` that describe problems found in the codebase.
|
|
145
|
+
|
|
146
|
+
### Bug format
|
|
147
|
+
|
|
148
|
+
\`\`\`yaml
|
|
149
|
+
---
|
|
150
|
+
title: "Login fails with empty password"
|
|
151
|
+
status: open
|
|
152
|
+
author: "user"
|
|
153
|
+
created-at: "2025-01-01T00:00:00.000Z"
|
|
154
|
+
---
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
- **status**: \`open\` (needs fixing) or \`resolved\` (already fixed)
|
|
158
|
+
|
|
159
|
+
### Bug workflow
|
|
160
|
+
|
|
161
|
+
1. Check for open bugs: \`sdd bug open\`
|
|
162
|
+
2. Read each open bug and fix the code and/or documentation
|
|
163
|
+
3. After fixing a bug, mark it: \`sdd mark-bug-resolved bugs/BUG-001.md\`
|
|
164
|
+
4. Commit the fix
|
|
165
|
+
|
|
166
|
+
### Bug commands
|
|
167
|
+
|
|
168
|
+
- \`sdd bug list\` — See all bugs and their status
|
|
169
|
+
- \`sdd bug open\` — Show only open bugs to fix
|
|
170
|
+
- \`sdd mark-bug-resolved [files...]\` — Mark bugs as resolved after fixing
|
|
171
|
+
|
|
127
172
|
## UX and screenshots
|
|
128
173
|
|
|
129
174
|
When a feature has UX mockups or screenshots, place them next to the feature doc:
|
|
@@ -155,6 +200,7 @@ Both formats work — use a folder only when you have screenshots or multiple fi
|
|
|
155
200
|
- \`system/\` — How to build it (entities, architecture, tech stack, interfaces)
|
|
156
201
|
- \`code/\` — All generated source code goes here
|
|
157
202
|
- \`change-requests/\` — Change requests to the documentation
|
|
203
|
+
- \`bugs/\` — Bug reports
|
|
158
204
|
- \`.sdd/\` — Project config and sync state (do not edit)
|
|
159
205
|
`;
|
|
160
206
|
const EMPTY_LOCK_TEMPLATE = () => `synced-at: "${new Date().toISOString()}"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/scaffold/templates.ts"],"names":[],"mappings":";;;AAAA,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAE3C,SAAS,UAAU,CAAC,KAAa,EAAE,OAAe;IAChD,OAAO;UACC,KAAK;;;kBAGG,GAAG,EAAE;;;;EAIrB,OAAO;CACR,CAAC;AACF,CAAC;AAMY,QAAA,iBAAiB,GAAG
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/scaffold/templates.ts"],"names":[],"mappings":";;;AAAA,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAE3C,SAAS,UAAU,CAAC,KAAa,EAAE,OAAe;IAChD,OAAO;UACC,KAAK;;;kBAGG,GAAG,EAAE;;;;EAIrB,OAAO;CACR,CAAC;AACF,CAAC;AAMY,QAAA,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4LhC,CAAC;AAEK,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;;CAE/E,CAAC;AAFW,QAAA,mBAAmB,uBAE9B"}
|
package/dist/sdd.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StoryStatus, ValidationResult, SDDConfig, ChangeRequest } from './types.js';
|
|
1
|
+
import type { StoryStatus, ValidationResult, SDDConfig, ChangeRequest, Bug } from './types.js';
|
|
2
2
|
import type { ProjectInfo } from './scaffold/templates.js';
|
|
3
3
|
export declare class SDD {
|
|
4
4
|
private root;
|
|
@@ -15,6 +15,9 @@ export declare class SDD {
|
|
|
15
15
|
changeRequests(): Promise<ChangeRequest[]>;
|
|
16
16
|
pendingChangeRequests(): Promise<ChangeRequest[]>;
|
|
17
17
|
markCRApplied(paths?: string[]): Promise<string[]>;
|
|
18
|
+
bugs(): Promise<Bug[]>;
|
|
19
|
+
openBugs(): Promise<Bug[]>;
|
|
20
|
+
markBugResolved(paths?: string[]): Promise<string[]>;
|
|
18
21
|
private ensureInitialized;
|
|
19
22
|
}
|
|
20
23
|
//# sourceMappingURL=sdd.d.ts.map
|
package/dist/sdd.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdd.d.ts","sourceRoot":"","sources":["../src/sdd.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"sdd.d.ts","sourceRoot":"","sources":["../src/sdd.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAS/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,qBAAa,GAAG;IACd,OAAO,CAAC,IAAI,CAAS;gBAET,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAI/B,IAAI,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAI3C,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC;IAK5B,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC;IAc9B,OAAO,IAAI,OAAO,CAAC,OAAO,YAAY,EAAE,SAAS,EAAE,CAAC;IAMpD,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAKvB,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAMrC,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA6B/C,cAAc,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAK1C,qBAAqB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAKjD,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmBlD,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAKtB,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAK1B,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmB1D,OAAO,CAAC,iBAAiB;CAK1B"}
|
package/dist/sdd.js
CHANGED
|
@@ -10,6 +10,7 @@ const validator_js_1 = require("./validate/validator.js");
|
|
|
10
10
|
const init_js_1 = require("./scaffold/init.js");
|
|
11
11
|
const config_manager_js_1 = require("./config/config-manager.js");
|
|
12
12
|
const cr_parser_js_1 = require("./parser/cr-parser.js");
|
|
13
|
+
const bug_parser_js_1 = require("./parser/bug-parser.js");
|
|
13
14
|
class SDD {
|
|
14
15
|
root;
|
|
15
16
|
constructor(options) {
|
|
@@ -100,6 +101,31 @@ class SDD {
|
|
|
100
101
|
}
|
|
101
102
|
return marked;
|
|
102
103
|
}
|
|
104
|
+
async bugs() {
|
|
105
|
+
this.ensureInitialized();
|
|
106
|
+
return (0, bug_parser_js_1.parseAllBugFiles)(this.root);
|
|
107
|
+
}
|
|
108
|
+
async openBugs() {
|
|
109
|
+
const all = await this.bugs();
|
|
110
|
+
return all.filter((b) => b.frontmatter.status === 'open');
|
|
111
|
+
}
|
|
112
|
+
async markBugResolved(paths) {
|
|
113
|
+
this.ensureInitialized();
|
|
114
|
+
const all = await this.bugs();
|
|
115
|
+
const marked = [];
|
|
116
|
+
for (const bug of all) {
|
|
117
|
+
if (bug.frontmatter.status === 'resolved')
|
|
118
|
+
continue;
|
|
119
|
+
if (paths && paths.length > 0 && !paths.includes(bug.relativePath))
|
|
120
|
+
continue;
|
|
121
|
+
const absPath = (0, node_path_1.resolve)(this.root, bug.relativePath);
|
|
122
|
+
const content = await (0, promises_1.readFile)(absPath, 'utf-8');
|
|
123
|
+
const updated = content.replace(/^status:\s*open/m, 'status: resolved');
|
|
124
|
+
await (0, promises_1.writeFile)(absPath, updated, 'utf-8');
|
|
125
|
+
marked.push(bug.relativePath);
|
|
126
|
+
}
|
|
127
|
+
return marked;
|
|
128
|
+
}
|
|
103
129
|
ensureInitialized() {
|
|
104
130
|
if (!(0, config_manager_js_1.isSDDProject)(this.root)) {
|
|
105
131
|
throw new errors_js_1.ProjectNotInitializedError(this.root);
|
package/dist/sdd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdd.js","sourceRoot":"","sources":["../src/sdd.ts"],"names":[],"mappings":";;;AAAA,+CAAuD;AACvD,yCAAoC;AAEpC,2CAAyD;AACzD,8DAA8D;AAC9D,sEAA8D;AAC9D,0DAAmD;AACnD,gDAAiD;AACjD,kEAAmF;AACnF,wDAAwD;
|
|
1
|
+
{"version":3,"file":"sdd.js","sourceRoot":"","sources":["../src/sdd.ts"],"names":[],"mappings":";;;AAAA,+CAAuD;AACvD,yCAAoC;AAEpC,2CAAyD;AACzD,8DAA8D;AAC9D,sEAA8D;AAC9D,0DAAmD;AACnD,gDAAiD;AACjD,kEAAmF;AACnF,wDAAwD;AACxD,0DAA0D;AAG1D,MAAa,GAAG;IACN,IAAI,CAAS;IAErB,YAAY,OAAyB;QACnC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAkB;QAC3B,OAAO,IAAA,qBAAW,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,OAAO,IAAA,8BAAU,EAAC,IAAI,CAAC,IAAI,CAA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C,IAAI,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AA3ID,kBA2IC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -62,4 +62,16 @@ export interface ChangeRequest {
|
|
|
62
62
|
frontmatter: ChangeRequestFrontmatter;
|
|
63
63
|
body: string;
|
|
64
64
|
}
|
|
65
|
+
export type BugStatus = 'open' | 'resolved';
|
|
66
|
+
export interface BugFrontmatter {
|
|
67
|
+
title: string;
|
|
68
|
+
status: BugStatus;
|
|
69
|
+
author: string;
|
|
70
|
+
'created-at': string;
|
|
71
|
+
}
|
|
72
|
+
export interface Bug {
|
|
73
|
+
relativePath: string;
|
|
74
|
+
frontmatter: BugFrontmatter;
|
|
75
|
+
body: string;
|
|
76
|
+
}
|
|
65
77
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;C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,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;QACjD,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,SAAS,CAAC;AAEtD,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,mBAAmB,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,wBAAwB,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,GAAG;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,cAAc,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applica-software-guru/sdd-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Core library for Story Driven Development",
|
|
5
|
+
"author": "Bruno Fortunato <bruno.fortunato@applica.guru>",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
7
8
|
"scripts": {
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,9 @@ export type {
|
|
|
13
13
|
ChangeRequest,
|
|
14
14
|
ChangeRequestFrontmatter,
|
|
15
15
|
ChangeRequestStatus,
|
|
16
|
+
Bug,
|
|
17
|
+
BugFrontmatter,
|
|
18
|
+
BugStatus,
|
|
16
19
|
} from './types.js';
|
|
17
20
|
export { SDDError, LockFileNotFoundError, ParseError, ProjectNotInitializedError } from './errors.js';
|
|
18
21
|
export type { ProjectInfo } from './scaffold/templates.js';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve, relative } from 'node:path';
|
|
3
|
+
import { glob } from 'glob';
|
|
4
|
+
import matter from 'gray-matter';
|
|
5
|
+
import type { Bug, BugFrontmatter } from '../types.js';
|
|
6
|
+
import { ParseError } from '../errors.js';
|
|
7
|
+
|
|
8
|
+
export async function discoverBugFiles(root: string): Promise<string[]> {
|
|
9
|
+
const pattern = 'bugs/*.md';
|
|
10
|
+
const matches = await glob(pattern, { cwd: root, absolute: true });
|
|
11
|
+
return matches.sort();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function parseBugFile(filePath: string, content: string): { frontmatter: BugFrontmatter; body: string } {
|
|
15
|
+
try {
|
|
16
|
+
const { data, content: body } = matter(content);
|
|
17
|
+
const frontmatter: BugFrontmatter = {
|
|
18
|
+
title: data.title ?? '',
|
|
19
|
+
status: data.status ?? 'open',
|
|
20
|
+
author: data.author ?? '',
|
|
21
|
+
'created-at': data['created-at'] ?? '',
|
|
22
|
+
};
|
|
23
|
+
return { frontmatter, body };
|
|
24
|
+
} catch (err) {
|
|
25
|
+
throw new ParseError(filePath, (err as Error).message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function parseAllBugFiles(root: string): Promise<Bug[]> {
|
|
30
|
+
const paths = await discoverBugFiles(root);
|
|
31
|
+
const results: Bug[] = [];
|
|
32
|
+
|
|
33
|
+
for (const absPath of paths) {
|
|
34
|
+
const content = await readFile(absPath, 'utf-8');
|
|
35
|
+
const relPath = relative(root, absPath);
|
|
36
|
+
const { frontmatter, body } = parseBugFile(relPath, content);
|
|
37
|
+
results.push({ relativePath: relPath, frontmatter, body });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return results;
|
|
41
|
+
}
|
package/src/scaffold/init.ts
CHANGED
|
@@ -29,7 +29,7 @@ export async function initProject(root: string, info?: ProjectInfo): Promise<str
|
|
|
29
29
|
createdFiles.push('.sdd/config.yaml');
|
|
30
30
|
|
|
31
31
|
// Create directory structure
|
|
32
|
-
const dirs = ['product', 'product/features', 'system', 'code', 'change-requests'];
|
|
32
|
+
const dirs = ['product', 'product/features', 'system', 'code', 'change-requests', 'bugs'];
|
|
33
33
|
for (const dir of dirs) {
|
|
34
34
|
const absDir = resolve(root, dir);
|
|
35
35
|
if (!existsSync(absDir)) {
|
|
@@ -24,12 +24,14 @@ Documentation drives implementation: read the docs first, then write code.
|
|
|
24
24
|
|
|
25
25
|
## Workflow
|
|
26
26
|
|
|
27
|
-
1. Run \`sdd
|
|
28
|
-
2. If there are
|
|
29
|
-
3. Run \`sdd
|
|
30
|
-
4.
|
|
31
|
-
5.
|
|
32
|
-
6.
|
|
27
|
+
1. Run \`sdd bug open\` — check if there are open bugs to fix first
|
|
28
|
+
2. If there are open bugs, fix the code/docs, then run \`sdd mark-bug-resolved\`
|
|
29
|
+
3. Run \`sdd cr pending\` — check if there are change requests to process
|
|
30
|
+
4. If there are pending CRs, apply them to the docs, then run \`sdd mark-cr-applied\`
|
|
31
|
+
5. Run \`sdd sync\` to see what needs to be implemented
|
|
32
|
+
6. Read the documentation files listed in the sync output
|
|
33
|
+
7. Implement what each file describes, writing code inside \`code/\`
|
|
34
|
+
8. After implementing, mark files as synced:
|
|
33
35
|
|
|
34
36
|
\`\`\`
|
|
35
37
|
sdd mark-synced product/features/auth.md
|
|
@@ -41,7 +43,7 @@ Or mark all pending files at once:
|
|
|
41
43
|
sdd mark-synced
|
|
42
44
|
\`\`\`
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
9. **Commit immediately after mark-synced** — this is mandatory:
|
|
45
47
|
|
|
46
48
|
\`\`\`
|
|
47
49
|
git add -A && git commit -m "sdd sync: <brief description of what was implemented>"
|
|
@@ -58,17 +60,20 @@ Delete the related code in \`code/\`, then run \`sdd mark-synced <file>\` (the d
|
|
|
58
60
|
|
|
59
61
|
- \`sdd status\` — See all documentation files and their state (new/changed/deleted/synced)
|
|
60
62
|
- \`sdd diff\` — See what changed since last sync
|
|
61
|
-
- \`sdd sync\` — Get the sync prompt for pending files (
|
|
63
|
+
- \`sdd sync\` — Get the sync prompt for pending files (includes git diff for changed files)
|
|
62
64
|
- \`sdd validate\` — Check for broken references and issues
|
|
63
65
|
- \`sdd mark-synced [files...]\` — Mark specific files (or all) as synced
|
|
64
66
|
- \`sdd cr list\` — List all change requests with their status
|
|
65
67
|
- \`sdd cr pending\` — Show draft change requests to process
|
|
66
68
|
- \`sdd mark-cr-applied [files...]\` — Mark change requests as applied
|
|
69
|
+
- \`sdd bug list\` — List all bugs with their status
|
|
70
|
+
- \`sdd bug open\` — Show open bugs to fix
|
|
71
|
+
- \`sdd mark-bug-resolved [files...]\` — Mark bugs as resolved
|
|
67
72
|
|
|
68
73
|
## Rules
|
|
69
74
|
|
|
70
75
|
1. **Always commit after mark-synced** — run \`git add -A && git commit -m "sdd sync: ..."\` immediately after \`sdd mark-synced\`. Never leave synced files uncommitted.
|
|
71
|
-
2. Before running \`sdd sync\`, check for pending change requests with \`sdd cr pending\`
|
|
76
|
+
2. Before running \`sdd sync\`, check for open bugs with \`sdd bug open\` and pending change requests with \`sdd cr pending\`
|
|
72
77
|
3. If there are pending CRs, apply them to the docs first, then mark them with \`sdd mark-cr-applied\`
|
|
73
78
|
4. Only implement what the sync prompt asks for
|
|
74
79
|
5. All generated code goes inside \`code/\`
|
|
@@ -97,6 +102,16 @@ version: "1.0"
|
|
|
97
102
|
- **version**: patch-bump on each edit (1.0 → 1.1 → 1.2)
|
|
98
103
|
- **last-modified**: ISO 8601 datetime, updated on each edit
|
|
99
104
|
|
|
105
|
+
## How sync works
|
|
106
|
+
|
|
107
|
+
\`sdd sync\` generates a structured prompt for the agent based on pending files:
|
|
108
|
+
|
|
109
|
+
- **\`new\` files**: the agent reads the full documentation and implements it from scratch
|
|
110
|
+
- **\`changed\` files**: SDD uses \`git diff\` to compute what changed in the documentation since the last commit, and includes the diff in the sync prompt — this way the agent sees exactly what was modified and can update only the affected code
|
|
111
|
+
- **\`deleted\` files**: the agent removes the related code
|
|
112
|
+
|
|
113
|
+
This is why **committing after every mark-synced is mandatory** — the git history is what SDD uses to detect changes.
|
|
114
|
+
|
|
100
115
|
## Change Requests
|
|
101
116
|
|
|
102
117
|
Change Requests (CRs) are markdown files in \`change-requests/\` that describe modifications to the documentation.
|
|
@@ -127,6 +142,36 @@ created-at: "2025-01-01T00:00:00.000Z"
|
|
|
127
142
|
- \`sdd cr pending\` — Show only draft CRs to process
|
|
128
143
|
- \`sdd mark-cr-applied [files...]\` — Mark CRs as applied after updating the docs
|
|
129
144
|
|
|
145
|
+
## Bugs
|
|
146
|
+
|
|
147
|
+
Bugs are markdown files in \`bugs/\` that describe problems found in the codebase.
|
|
148
|
+
|
|
149
|
+
### Bug format
|
|
150
|
+
|
|
151
|
+
\`\`\`yaml
|
|
152
|
+
---
|
|
153
|
+
title: "Login fails with empty password"
|
|
154
|
+
status: open
|
|
155
|
+
author: "user"
|
|
156
|
+
created-at: "2025-01-01T00:00:00.000Z"
|
|
157
|
+
---
|
|
158
|
+
\`\`\`
|
|
159
|
+
|
|
160
|
+
- **status**: \`open\` (needs fixing) or \`resolved\` (already fixed)
|
|
161
|
+
|
|
162
|
+
### Bug workflow
|
|
163
|
+
|
|
164
|
+
1. Check for open bugs: \`sdd bug open\`
|
|
165
|
+
2. Read each open bug and fix the code and/or documentation
|
|
166
|
+
3. After fixing a bug, mark it: \`sdd mark-bug-resolved bugs/BUG-001.md\`
|
|
167
|
+
4. Commit the fix
|
|
168
|
+
|
|
169
|
+
### Bug commands
|
|
170
|
+
|
|
171
|
+
- \`sdd bug list\` — See all bugs and their status
|
|
172
|
+
- \`sdd bug open\` — Show only open bugs to fix
|
|
173
|
+
- \`sdd mark-bug-resolved [files...]\` — Mark bugs as resolved after fixing
|
|
174
|
+
|
|
130
175
|
## UX and screenshots
|
|
131
176
|
|
|
132
177
|
When a feature has UX mockups or screenshots, place them next to the feature doc:
|
|
@@ -158,6 +203,7 @@ Both formats work — use a folder only when you have screenshots or multiple fi
|
|
|
158
203
|
- \`system/\` — How to build it (entities, architecture, tech stack, interfaces)
|
|
159
204
|
- \`code/\` — All generated source code goes here
|
|
160
205
|
- \`change-requests/\` — Change requests to the documentation
|
|
206
|
+
- \`bugs/\` — Bug reports
|
|
161
207
|
- \`.sdd/\` — Project config and sync state (do not edit)
|
|
162
208
|
`;
|
|
163
209
|
|
package/src/sdd.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import type { StoryStatus, ValidationResult, SDDConfig, ChangeRequest } from './types.js';
|
|
3
|
+
import type { StoryStatus, ValidationResult, SDDConfig, ChangeRequest, Bug } from './types.js';
|
|
4
4
|
import { ProjectNotInitializedError } from './errors.js';
|
|
5
5
|
import { parseAllStoryFiles } from './parser/story-parser.js';
|
|
6
6
|
import { generatePrompt } from './prompt/prompt-generator.js';
|
|
@@ -8,6 +8,7 @@ import { validate } from './validate/validator.js';
|
|
|
8
8
|
import { initProject } from './scaffold/init.js';
|
|
9
9
|
import { isSDDProject, readConfig, writeConfig } from './config/config-manager.js';
|
|
10
10
|
import { parseAllCRFiles } from './parser/cr-parser.js';
|
|
11
|
+
import { parseAllBugFiles } from './parser/bug-parser.js';
|
|
11
12
|
import type { ProjectInfo } from './scaffold/templates.js';
|
|
12
13
|
|
|
13
14
|
export class SDD {
|
|
@@ -115,6 +116,35 @@ export class SDD {
|
|
|
115
116
|
return marked;
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
async bugs(): Promise<Bug[]> {
|
|
120
|
+
this.ensureInitialized();
|
|
121
|
+
return parseAllBugFiles(this.root);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async openBugs(): Promise<Bug[]> {
|
|
125
|
+
const all = await this.bugs();
|
|
126
|
+
return all.filter((b) => b.frontmatter.status === 'open');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async markBugResolved(paths?: string[]): Promise<string[]> {
|
|
130
|
+
this.ensureInitialized();
|
|
131
|
+
const all = await this.bugs();
|
|
132
|
+
const marked: string[] = [];
|
|
133
|
+
|
|
134
|
+
for (const bug of all) {
|
|
135
|
+
if (bug.frontmatter.status === 'resolved') continue;
|
|
136
|
+
if (paths && paths.length > 0 && !paths.includes(bug.relativePath)) continue;
|
|
137
|
+
|
|
138
|
+
const absPath = resolve(this.root, bug.relativePath);
|
|
139
|
+
const content = await readFile(absPath, 'utf-8');
|
|
140
|
+
const updated = content.replace(/^status:\s*open/m, 'status: resolved');
|
|
141
|
+
await writeFile(absPath, updated, 'utf-8');
|
|
142
|
+
marked.push(bug.relativePath);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return marked;
|
|
146
|
+
}
|
|
147
|
+
|
|
118
148
|
private ensureInitialized(): void {
|
|
119
149
|
if (!isSDDProject(this.root)) {
|
|
120
150
|
throw new ProjectNotInitializedError(this.root);
|
package/src/types.ts
CHANGED
|
@@ -74,3 +74,18 @@ export interface ChangeRequest {
|
|
|
74
74
|
frontmatter: ChangeRequestFrontmatter;
|
|
75
75
|
body: string;
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
export type BugStatus = 'open' | 'resolved';
|
|
79
|
+
|
|
80
|
+
export interface BugFrontmatter {
|
|
81
|
+
title: string;
|
|
82
|
+
status: BugStatus;
|
|
83
|
+
author: string;
|
|
84
|
+
'created-at': string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface Bug {
|
|
88
|
+
relativePath: string;
|
|
89
|
+
frontmatter: BugFrontmatter;
|
|
90
|
+
body: string;
|
|
91
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { mkdtemp, rm, writeFile, readFile, mkdir } from 'node:fs/promises';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { SDD } from '../src/sdd.js';
|
|
7
|
+
import { parseBugFile, discoverBugFiles } from '../src/parser/bug-parser.js';
|
|
8
|
+
|
|
9
|
+
const BUG_OPEN = `---
|
|
10
|
+
title: "Login fails with empty password"
|
|
11
|
+
status: open
|
|
12
|
+
author: "user"
|
|
13
|
+
created-at: "2025-01-01T00:00:00.000Z"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Description
|
|
17
|
+
|
|
18
|
+
When the user submits the login form with an empty password, the app crashes.
|
|
19
|
+
|
|
20
|
+
## Steps to reproduce
|
|
21
|
+
|
|
22
|
+
1. Go to /login
|
|
23
|
+
2. Enter email but leave password empty
|
|
24
|
+
3. Click "Login"
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const BUG_RESOLVED = `---
|
|
28
|
+
title: "Navigation bar misaligned"
|
|
29
|
+
status: resolved
|
|
30
|
+
author: "user"
|
|
31
|
+
created-at: "2025-01-02T00:00:00.000Z"
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Description
|
|
35
|
+
|
|
36
|
+
The navigation bar is misaligned on mobile devices.
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
describe('Bug parser', () => {
|
|
40
|
+
it('parses bug frontmatter correctly', () => {
|
|
41
|
+
const result = parseBugFile('bugs/BUG-001.md', BUG_OPEN);
|
|
42
|
+
expect(result.frontmatter.title).toBe('Login fails with empty password');
|
|
43
|
+
expect(result.frontmatter.status).toBe('open');
|
|
44
|
+
expect(result.frontmatter.author).toBe('user');
|
|
45
|
+
expect(result.frontmatter['created-at']).toBe('2025-01-01T00:00:00.000Z');
|
|
46
|
+
expect(result.body).toContain('## Description');
|
|
47
|
+
expect(result.body).toContain('empty password');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('provides defaults for missing fields', () => {
|
|
51
|
+
const content = `---
|
|
52
|
+
title: "Minimal bug"
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
Some body.
|
|
56
|
+
`;
|
|
57
|
+
const result = parseBugFile('test.md', content);
|
|
58
|
+
expect(result.frontmatter.status).toBe('open');
|
|
59
|
+
expect(result.frontmatter.author).toBe('');
|
|
60
|
+
expect(result.frontmatter['created-at']).toBe('');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('Bug file discovery', () => {
|
|
65
|
+
let tempDir: string;
|
|
66
|
+
|
|
67
|
+
beforeEach(async () => {
|
|
68
|
+
tempDir = await mkdtemp(join(tmpdir(), 'sdd-bug-discovery-'));
|
|
69
|
+
await mkdir(join(tempDir, 'bugs'), { recursive: true });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
afterEach(async () => {
|
|
73
|
+
await rm(tempDir, { recursive: true });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('discovers .md files in bugs/', async () => {
|
|
77
|
+
await writeFile(join(tempDir, 'bugs/BUG-001.md'), BUG_OPEN, 'utf-8');
|
|
78
|
+
await writeFile(join(tempDir, 'bugs/BUG-002.md'), BUG_RESOLVED, 'utf-8');
|
|
79
|
+
|
|
80
|
+
const files = await discoverBugFiles(tempDir);
|
|
81
|
+
expect(files).toHaveLength(2);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('returns empty array when no bug files exist', async () => {
|
|
85
|
+
const files = await discoverBugFiles(tempDir);
|
|
86
|
+
expect(files).toHaveLength(0);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('SDD Bug methods', () => {
|
|
91
|
+
let tempDir: string;
|
|
92
|
+
let sdd: SDD;
|
|
93
|
+
|
|
94
|
+
beforeEach(async () => {
|
|
95
|
+
tempDir = await mkdtemp(join(tmpdir(), 'sdd-bug-'));
|
|
96
|
+
sdd = new SDD({ root: tempDir });
|
|
97
|
+
await sdd.init({ description: 'test' });
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
afterEach(async () => {
|
|
101
|
+
await rm(tempDir, { recursive: true });
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('bugs() returns all bugs', async () => {
|
|
105
|
+
await writeFile(join(tempDir, 'bugs/BUG-001.md'), BUG_OPEN, 'utf-8');
|
|
106
|
+
await writeFile(join(tempDir, 'bugs/BUG-002.md'), BUG_RESOLVED, 'utf-8');
|
|
107
|
+
|
|
108
|
+
const bugs = await sdd.bugs();
|
|
109
|
+
expect(bugs).toHaveLength(2);
|
|
110
|
+
expect(bugs[0].frontmatter.title).toBe('Login fails with empty password');
|
|
111
|
+
expect(bugs[1].frontmatter.title).toBe('Navigation bar misaligned');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('openBugs() returns only open bugs', async () => {
|
|
115
|
+
await writeFile(join(tempDir, 'bugs/BUG-001.md'), BUG_OPEN, 'utf-8');
|
|
116
|
+
await writeFile(join(tempDir, 'bugs/BUG-002.md'), BUG_RESOLVED, 'utf-8');
|
|
117
|
+
|
|
118
|
+
const open = await sdd.openBugs();
|
|
119
|
+
expect(open).toHaveLength(1);
|
|
120
|
+
expect(open[0].frontmatter.status).toBe('open');
|
|
121
|
+
expect(open[0].frontmatter.title).toBe('Login fails with empty password');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('markBugResolved() changes open to resolved', async () => {
|
|
125
|
+
await writeFile(join(tempDir, 'bugs/BUG-001.md'), BUG_OPEN, 'utf-8');
|
|
126
|
+
|
|
127
|
+
const marked = await sdd.markBugResolved(['bugs/BUG-001.md']);
|
|
128
|
+
expect(marked).toEqual(['bugs/BUG-001.md']);
|
|
129
|
+
|
|
130
|
+
const content = await readFile(join(tempDir, 'bugs/BUG-001.md'), 'utf-8');
|
|
131
|
+
expect(content).toContain('status: resolved');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('markBugResolved() without args marks all open bugs', async () => {
|
|
135
|
+
await writeFile(join(tempDir, 'bugs/BUG-001.md'), BUG_OPEN, 'utf-8');
|
|
136
|
+
const open2 = BUG_OPEN.replace('Login fails with empty password', 'Second bug');
|
|
137
|
+
await writeFile(join(tempDir, 'bugs/BUG-002.md'), open2, 'utf-8');
|
|
138
|
+
|
|
139
|
+
const marked = await sdd.markBugResolved();
|
|
140
|
+
expect(marked).toHaveLength(2);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('markBugResolved() skips already resolved bugs', async () => {
|
|
144
|
+
await writeFile(join(tempDir, 'bugs/BUG-001.md'), BUG_RESOLVED, 'utf-8');
|
|
145
|
+
|
|
146
|
+
const marked = await sdd.markBugResolved();
|
|
147
|
+
expect(marked).toHaveLength(0);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('integration: create bug → open → mark resolved → no longer open', async () => {
|
|
151
|
+
await writeFile(join(tempDir, 'bugs/BUG-001.md'), BUG_OPEN, 'utf-8');
|
|
152
|
+
|
|
153
|
+
// Should be open
|
|
154
|
+
let open = await sdd.openBugs();
|
|
155
|
+
expect(open).toHaveLength(1);
|
|
156
|
+
|
|
157
|
+
// Mark as resolved
|
|
158
|
+
await sdd.markBugResolved();
|
|
159
|
+
|
|
160
|
+
// Should no longer be open
|
|
161
|
+
open = await sdd.openBugs();
|
|
162
|
+
expect(open).toHaveLength(0);
|
|
163
|
+
|
|
164
|
+
// But still in the full list
|
|
165
|
+
const all = await sdd.bugs();
|
|
166
|
+
expect(all).toHaveLength(1);
|
|
167
|
+
expect(all[0].frontmatter.status).toBe('resolved');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('init creates bugs/ directory', async () => {
|
|
171
|
+
expect(existsSync(join(tempDir, 'bugs'))).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
});
|