ai-spector 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -0
- package/_templates/basic_design/db-design-template.md +177 -0
- package/_templates/basic_design/detail-api-template.md +278 -0
- package/_templates/basic_design/detail-screen-template.md +281 -0
- package/_templates/basic_design/list-api-template.md +130 -0
- package/_templates/basic_design/list-screen-template.md +242 -0
- package/_templates/detail_design/common/architecture-overview-template.md +302 -0
- package/_templates/detail_design/common/deployment-infrastructure-template.md +461 -0
- package/_templates/detail_design/common/error-handling-patterns-template.md +460 -0
- package/_templates/detail_design/common/integration-patterns-template.md +410 -0
- package/_templates/detail_design/common/performance-standards-template.md +406 -0
- package/_templates/detail_design/common/security-patterns-template.md +395 -0
- package/_templates/detail_design/feature-detail-design-template.md +773 -0
- package/_templates/detail_design/feature-list-template.md +39 -0
- package/_templates/srs/1-introduction.md +58 -0
- package/_templates/srs/2-overall-description.md +91 -0
- package/_templates/srs/3-use-case-detail-template.md +142 -0
- package/_templates/srs/3-use-cases.md +53 -0
- package/_templates/srs/4-system-feature-detail-template.md +131 -0
- package/_templates/srs/4-system-features-list-template.md +39 -0
- package/_templates/srs/5-data-requirements.md +59 -0
- package/_templates/srs/6-external-interfaces.md +56 -0
- package/_templates/srs/7-quality-attributes.md +74 -0
- package/_templates/srs/8-internationalization.md +36 -0
- package/_templates/srs/9-other-requirements.md +46 -0
- package/assets/cursor/commands/analyze.md +39 -0
- package/assets/cursor/commands/generate-detail-design.md +35 -0
- package/assets/cursor/commands/generate-srs.md +38 -0
- package/assets/cursor/skills/spec-writer/SKILL.md +33 -0
- package/assets/workflow/config/analyze.graphify.json +36 -0
- package/assets/workflow/config/completeness-rules.detail-design.json +57 -0
- package/assets/workflow/config/completeness-rules.srs.json +72 -0
- package/assets/workflow/config/dag.detail-design.json +64 -0
- package/assets/workflow/config/dag.srs.json +87 -0
- package/assets/workflow/state/state.template.json +26 -0
- package/assets/workflow/templates/basic_design/db-design-template.md +177 -0
- package/assets/workflow/templates/basic_design/detail-api-template.md +278 -0
- package/assets/workflow/templates/basic_design/detail-screen-template.md +281 -0
- package/assets/workflow/templates/basic_design/list-api-template.md +130 -0
- package/assets/workflow/templates/basic_design/list-screen-template.md +242 -0
- package/assets/workflow/templates/detail_design/common/architecture-overview-template.md +302 -0
- package/assets/workflow/templates/detail_design/common/deployment-infrastructure-template.md +461 -0
- package/assets/workflow/templates/detail_design/common/error-handling-patterns-template.md +460 -0
- package/assets/workflow/templates/detail_design/common/integration-patterns-template.md +410 -0
- package/assets/workflow/templates/detail_design/common/performance-standards-template.md +406 -0
- package/assets/workflow/templates/detail_design/common/security-patterns-template.md +395 -0
- package/assets/workflow/templates/detail_design/feature-detail-design-template.md +773 -0
- package/assets/workflow/templates/detail_design/feature-list-template.md +39 -0
- package/assets/workflow/templates/srs/1-introduction.md +58 -0
- package/assets/workflow/templates/srs/2-overall-description.md +91 -0
- package/assets/workflow/templates/srs/3-use-case-detail-template.md +142 -0
- package/assets/workflow/templates/srs/3-use-cases.md +53 -0
- package/assets/workflow/templates/srs/4-system-feature-detail-template.md +131 -0
- package/assets/workflow/templates/srs/4-system-features-list-template.md +39 -0
- package/assets/workflow/templates/srs/5-data-requirements.md +59 -0
- package/assets/workflow/templates/srs/6-external-interfaces.md +56 -0
- package/assets/workflow/templates/srs/7-quality-attributes.md +74 -0
- package/assets/workflow/templates/srs/8-internationalization.md +36 -0
- package/assets/workflow/templates/srs/9-other-requirements.md +46 -0
- package/bin/spec-writer.js +56 -0
- package/package.json +25 -0
- package/src/cli/helpers/fs.js +50 -0
- package/src/cli/init.js +178 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
## 7. Non-Functional Requirements (Quality Attributes)
|
|
2
|
+
|
|
3
|
+
> This section specifies the non-functional requirements that define the quality attributes, constraints, and performance characteristics of the system. These requirements describe how the system should behave rather than what functions it should perform.
|
|
4
|
+
|
|
5
|
+
### 7.1 Usability
|
|
6
|
+
|
|
7
|
+
> Specify any requirements regarding characteristics that will make the software appear to be "user-friendly."
|
|
8
|
+
|
|
9
|
+
**Requirements:**
|
|
10
|
+
- **Ease of Use:** <Requirement>
|
|
11
|
+
- **Ease of Learning:** <Requirement>
|
|
12
|
+
- **Accessibility:** <Requirement>
|
|
13
|
+
- **Error Handling:** <Requirement>
|
|
14
|
+
|
|
15
|
+
**UI Design Standards:**
|
|
16
|
+
- <Standard 1>
|
|
17
|
+
- <Standard 2>
|
|
18
|
+
|
|
19
|
+
### 7.2 Performance
|
|
20
|
+
|
|
21
|
+
> State specific performance requirements for various system operations.
|
|
22
|
+
|
|
23
|
+
| Operation | Response Time Requirement |
|
|
24
|
+
|-----------|---------------------------|
|
|
25
|
+
| <Operation 1> | <Time requirement> |
|
|
26
|
+
| <Operation 2> | <Time requirement> |
|
|
27
|
+
|
|
28
|
+
**Throughput Requirements:**
|
|
29
|
+
- <Requirement 1>
|
|
30
|
+
- <Requirement 2>
|
|
31
|
+
|
|
32
|
+
### 7.3 Security
|
|
33
|
+
|
|
34
|
+
> Specify any requirements regarding security or privacy issues.
|
|
35
|
+
|
|
36
|
+
**Requirements:**
|
|
37
|
+
- **Access Control:** <Requirement>
|
|
38
|
+
- **Authentication:** <Requirement>
|
|
39
|
+
- **Authorization:** <Requirement>
|
|
40
|
+
- **Data Security:** <Requirement>
|
|
41
|
+
- **Privacy:** <Requirement>
|
|
42
|
+
|
|
43
|
+
**Compliance:**
|
|
44
|
+
- <Compliance requirement 1>
|
|
45
|
+
- <Compliance requirement 2>
|
|
46
|
+
|
|
47
|
+
### 7.4 Safety
|
|
48
|
+
|
|
49
|
+
> Specify requirements that are concerned with possible loss, damage, or harm.
|
|
50
|
+
|
|
51
|
+
**Requirements:**
|
|
52
|
+
- <Requirement 1>
|
|
53
|
+
- <Requirement 2>
|
|
54
|
+
|
|
55
|
+
**Safeguards:**
|
|
56
|
+
- <Safeguard 1>
|
|
57
|
+
- <Safeguard 2>
|
|
58
|
+
|
|
59
|
+
### 7.5 Others as relevant
|
|
60
|
+
|
|
61
|
+
> Create a separate section for each additional product quality attribute.
|
|
62
|
+
|
|
63
|
+
**Availability:**
|
|
64
|
+
- <Requirement 1>
|
|
65
|
+
- <Requirement 2>
|
|
66
|
+
|
|
67
|
+
**Reliability:**
|
|
68
|
+
- <Requirement 1>
|
|
69
|
+
- <Requirement 2>
|
|
70
|
+
|
|
71
|
+
**Maintainability:**
|
|
72
|
+
- <Requirement 1>
|
|
73
|
+
- <Requirement 2>
|
|
74
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
## 8. Internationalization and Localization Requirements
|
|
2
|
+
|
|
3
|
+
> Internationalization and localization requirements ensure that the product will be suitable for use in nations, cultures, and geographic locations other than those in which it was created.
|
|
4
|
+
|
|
5
|
+
**Supported Languages:**
|
|
6
|
+
|
|
7
|
+
- <Language 1>
|
|
8
|
+
- <Language 2>
|
|
9
|
+
|
|
10
|
+
**Supported Locales:**
|
|
11
|
+
|
|
12
|
+
- <Locale 1>
|
|
13
|
+
- <Locale 2>
|
|
14
|
+
|
|
15
|
+
**Formatting Requirements:**
|
|
16
|
+
|
|
17
|
+
- **Currency:**
|
|
18
|
+
- **Date/Time:**
|
|
19
|
+
- **Numbers:**
|
|
20
|
+
- **Addresses:**
|
|
21
|
+
|
|
22
|
+
**Character Sets:**
|
|
23
|
+
|
|
24
|
+
- <Requirement 1>
|
|
25
|
+
- <Requirement 2>
|
|
26
|
+
|
|
27
|
+
**Cultural Considerations:**
|
|
28
|
+
|
|
29
|
+
- <Consideration 1>
|
|
30
|
+
- <Consideration 2>
|
|
31
|
+
|
|
32
|
+
**Regulatory Compliance:**
|
|
33
|
+
|
|
34
|
+
- <Regulation 1>
|
|
35
|
+
- <Regulation 2>
|
|
36
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
## 9. Other Requirements
|
|
2
|
+
|
|
3
|
+
> Examples are: legal, regulatory or financial compliance, and standards requirements; requirements for product installation, configuration, startup, and shutdown; and logging, monitoring and audit trail requirements.
|
|
4
|
+
|
|
5
|
+
### 9.1 Legal and Regulatory Compliance
|
|
6
|
+
|
|
7
|
+
**Legal Requirements:**
|
|
8
|
+
- <Requirement 1>
|
|
9
|
+
- <Requirement 2>
|
|
10
|
+
|
|
11
|
+
**Regulatory Compliance:**
|
|
12
|
+
- <Compliance requirement 1>
|
|
13
|
+
- <Compliance requirement 2>
|
|
14
|
+
|
|
15
|
+
**Standards Compliance:**
|
|
16
|
+
- <Standard 1>
|
|
17
|
+
- <Standard 2>
|
|
18
|
+
|
|
19
|
+
### 9.2 Installation and Configuration
|
|
20
|
+
|
|
21
|
+
**Installation Requirements:**
|
|
22
|
+
- <Requirement 1>
|
|
23
|
+
- <Requirement 2>
|
|
24
|
+
|
|
25
|
+
**Configuration Requirements:**
|
|
26
|
+
- <Requirement 1>
|
|
27
|
+
- <Requirement 2>
|
|
28
|
+
|
|
29
|
+
**Startup/Shutdown Requirements:**
|
|
30
|
+
- <Requirement 1>
|
|
31
|
+
- <Requirement 2>
|
|
32
|
+
|
|
33
|
+
### 9.3 Logging and Monitoring
|
|
34
|
+
|
|
35
|
+
**Logging Requirements:**
|
|
36
|
+
- <Requirement 1>
|
|
37
|
+
- <Requirement 2>
|
|
38
|
+
|
|
39
|
+
**Monitoring Requirements:**
|
|
40
|
+
- <Requirement 1>
|
|
41
|
+
- <Requirement 2>
|
|
42
|
+
|
|
43
|
+
**Audit Trail Requirements:**
|
|
44
|
+
- <Requirement 1>
|
|
45
|
+
- <Requirement 2>
|
|
46
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { runInit } = require("../src/cli/init");
|
|
4
|
+
|
|
5
|
+
function parseArgs(argv) {
|
|
6
|
+
const [command, ...rest] = argv;
|
|
7
|
+
const flags = {
|
|
8
|
+
yes: false,
|
|
9
|
+
force: false,
|
|
10
|
+
noGraphify: false,
|
|
11
|
+
skipIndex: false
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
for (const arg of rest) {
|
|
15
|
+
if (arg === "--yes" || arg === "-y") flags.yes = true;
|
|
16
|
+
if (arg === "--force" || arg === "-f") flags.force = true;
|
|
17
|
+
if (arg === "--no-graphify") flags.noGraphify = true;
|
|
18
|
+
if (arg === "--skip-index") flags.skipIndex = true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return { command, flags };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function printHelp() {
|
|
25
|
+
console.log(`spec-writer
|
|
26
|
+
|
|
27
|
+
Usage:
|
|
28
|
+
spec-writer init [--yes] [--force] [--no-graphify] [--skip-index]
|
|
29
|
+
|
|
30
|
+
Commands:
|
|
31
|
+
init Install Cursor commands, skill, templates, and workflow files.
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function main() {
|
|
36
|
+
const { command, flags } = parseArgs(process.argv.slice(2));
|
|
37
|
+
|
|
38
|
+
if (!command || command === "--help" || command === "-h") {
|
|
39
|
+
printHelp();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (command === "init") {
|
|
44
|
+
await runInit(process.cwd(), flags);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.error(`Unknown command: ${command}`);
|
|
49
|
+
printHelp();
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
main().catch((error) => {
|
|
54
|
+
console.error(error.message);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ai-spector",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Cursor skill and workflow bootstrapper for incremental SRS/detail design generation.",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ai-spector": "bin/spec-writer.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"cursor",
|
|
11
|
+
"documentation",
|
|
12
|
+
"srs",
|
|
13
|
+
"workflow",
|
|
14
|
+
"graphify"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"start": "node bin/spec-writer.js",
|
|
22
|
+
"init:local": "node bin/spec-writer.js init",
|
|
23
|
+
"lint": "node -e \"console.log('No linter configured yet')\""
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
function ensureDir(targetDir) {
|
|
5
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function copyRecursive(sourcePath, targetPath, options = {}) {
|
|
9
|
+
const { overwrite = false } = options;
|
|
10
|
+
const stat = fs.statSync(sourcePath);
|
|
11
|
+
|
|
12
|
+
if (stat.isDirectory()) {
|
|
13
|
+
ensureDir(targetPath);
|
|
14
|
+
for (const entry of fs.readdirSync(sourcePath)) {
|
|
15
|
+
copyRecursive(
|
|
16
|
+
path.join(sourcePath, entry),
|
|
17
|
+
path.join(targetPath, entry),
|
|
18
|
+
options
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!overwrite && fs.existsSync(targetPath)) return;
|
|
25
|
+
ensureDir(path.dirname(targetPath));
|
|
26
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function writeJson(targetPath, data, options = {}) {
|
|
30
|
+
const { overwrite = false } = options;
|
|
31
|
+
if (!overwrite && fs.existsSync(targetPath)) return;
|
|
32
|
+
ensureDir(path.dirname(targetPath));
|
|
33
|
+
fs.writeFileSync(targetPath, JSON.stringify(data, null, 2) + "\n", "utf8");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function readJson(targetPath, fallback = {}) {
|
|
37
|
+
try {
|
|
38
|
+
const raw = fs.readFileSync(targetPath, "utf8");
|
|
39
|
+
return JSON.parse(raw);
|
|
40
|
+
} catch (_err) {
|
|
41
|
+
return fallback;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
ensureDir,
|
|
47
|
+
copyRecursive,
|
|
48
|
+
writeJson,
|
|
49
|
+
readJson
|
|
50
|
+
};
|
package/src/cli/init.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
const { ensureDir, copyRecursive, writeJson, readJson } = require("./helpers/fs");
|
|
5
|
+
|
|
6
|
+
function getPackageRoot() {
|
|
7
|
+
return path.resolve(__dirname, "../..");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function targetPaths(cwd) {
|
|
11
|
+
return {
|
|
12
|
+
cursorCommands: path.join(cwd, ".cursor/commands"),
|
|
13
|
+
cursorSkill: path.join(cwd, ".cursor/skills/spec-writer"),
|
|
14
|
+
docsRoot: path.join(cwd, "docs"),
|
|
15
|
+
templates: path.join(cwd, "docs/_templates"),
|
|
16
|
+
docflowRoot: path.join(cwd, "docs/.docflow"),
|
|
17
|
+
graphIndex: path.join(cwd, "docs/.docflow/graph/graphify-index"),
|
|
18
|
+
analysis: path.join(cwd, "docs/.docflow/analysis"),
|
|
19
|
+
partialsSrs: path.join(cwd, "docs/.docflow/partials/srs"),
|
|
20
|
+
partialsDetail: path.join(cwd, "docs/.docflow/partials/detail-design"),
|
|
21
|
+
logs: path.join(cwd, "docs/.docflow/logs"),
|
|
22
|
+
config: path.join(cwd, "docs/.docflow/config"),
|
|
23
|
+
outputSrs: path.join(cwd, "docs/output/srs"),
|
|
24
|
+
outputDetail: path.join(cwd, "docs/output/detail-design")
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function installGraphify(cwd) {
|
|
29
|
+
const detect = spawnSync("npx", ["--yes", "graphify", "--help"], {
|
|
30
|
+
cwd,
|
|
31
|
+
stdio: "ignore"
|
|
32
|
+
});
|
|
33
|
+
if (detect.status === 0) return { installed: false, available: true };
|
|
34
|
+
|
|
35
|
+
const install = spawnSync("npm", ["install", "--save-dev", "graphify"], {
|
|
36
|
+
cwd,
|
|
37
|
+
stdio: "inherit"
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
installed: install.status === 0,
|
|
41
|
+
available: install.status === 0
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function runInitialGraphifyIndex(cwd, graphConfigPath) {
|
|
46
|
+
const args = [
|
|
47
|
+
"--yes",
|
|
48
|
+
"graphify",
|
|
49
|
+
"index",
|
|
50
|
+
"--config",
|
|
51
|
+
graphConfigPath
|
|
52
|
+
];
|
|
53
|
+
const result = spawnSync("npx", args, { cwd, stdio: "inherit" });
|
|
54
|
+
return result.status === 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function installAssets(cwd, options) {
|
|
58
|
+
const pkgRoot = getPackageRoot();
|
|
59
|
+
const t = targetPaths(cwd);
|
|
60
|
+
|
|
61
|
+
const copyOptions = { overwrite: Boolean(options.force) };
|
|
62
|
+
|
|
63
|
+
ensureDir(t.cursorCommands);
|
|
64
|
+
ensureDir(t.cursorSkill);
|
|
65
|
+
ensureDir(t.docsRoot);
|
|
66
|
+
ensureDir(t.templates);
|
|
67
|
+
ensureDir(t.graphIndex);
|
|
68
|
+
ensureDir(t.analysis);
|
|
69
|
+
ensureDir(t.partialsSrs);
|
|
70
|
+
ensureDir(t.partialsDetail);
|
|
71
|
+
ensureDir(t.logs);
|
|
72
|
+
ensureDir(t.config);
|
|
73
|
+
ensureDir(t.outputSrs);
|
|
74
|
+
ensureDir(t.outputDetail);
|
|
75
|
+
|
|
76
|
+
copyRecursive(
|
|
77
|
+
path.join(pkgRoot, "assets/cursor/commands"),
|
|
78
|
+
t.cursorCommands,
|
|
79
|
+
copyOptions
|
|
80
|
+
);
|
|
81
|
+
copyRecursive(
|
|
82
|
+
path.join(pkgRoot, "assets/cursor/skills/spec-writer"),
|
|
83
|
+
t.cursorSkill,
|
|
84
|
+
copyOptions
|
|
85
|
+
);
|
|
86
|
+
copyRecursive(
|
|
87
|
+
path.join(pkgRoot, "assets/workflow/templates"),
|
|
88
|
+
t.templates,
|
|
89
|
+
copyOptions
|
|
90
|
+
);
|
|
91
|
+
copyRecursive(
|
|
92
|
+
path.join(pkgRoot, "assets/workflow/config"),
|
|
93
|
+
t.config,
|
|
94
|
+
copyOptions
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const stateTemplatePath = path.join(
|
|
98
|
+
pkgRoot,
|
|
99
|
+
"assets/workflow/state/state.template.json"
|
|
100
|
+
);
|
|
101
|
+
const stateOutputPath = path.join(t.docflowRoot, "state.json");
|
|
102
|
+
const template = readJson(stateTemplatePath, {});
|
|
103
|
+
writeJson(stateOutputPath, template, copyOptions);
|
|
104
|
+
|
|
105
|
+
const defaultAnalysisFiles = {
|
|
106
|
+
knowledgeVersion: 1,
|
|
107
|
+
generatedAt: null,
|
|
108
|
+
scope: [],
|
|
109
|
+
actors: [],
|
|
110
|
+
useCases: [],
|
|
111
|
+
features: [],
|
|
112
|
+
functionalRequirements: [],
|
|
113
|
+
nfrs: [],
|
|
114
|
+
entities: [],
|
|
115
|
+
interfaces: [],
|
|
116
|
+
constraints: [],
|
|
117
|
+
openQuestions: []
|
|
118
|
+
};
|
|
119
|
+
const defaultGaps = {
|
|
120
|
+
generatedAt: null,
|
|
121
|
+
missingSections: [],
|
|
122
|
+
notes: []
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
writeJson(
|
|
126
|
+
path.join(t.analysis, "knowledge.json"),
|
|
127
|
+
defaultAnalysisFiles,
|
|
128
|
+
copyOptions
|
|
129
|
+
);
|
|
130
|
+
writeJson(path.join(t.analysis, "gaps.json"), defaultGaps, copyOptions);
|
|
131
|
+
writeJson(
|
|
132
|
+
path.join(t.analysis, "scope.json"),
|
|
133
|
+
{ sources: [], mode: "workspace", analyzedAt: null },
|
|
134
|
+
copyOptions
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function runInit(cwd, options) {
|
|
139
|
+
installAssets(cwd, options);
|
|
140
|
+
const t = targetPaths(cwd);
|
|
141
|
+
|
|
142
|
+
let graphifyReady = false;
|
|
143
|
+
let graphifyInstalled = false;
|
|
144
|
+
|
|
145
|
+
if (!options.noGraphify) {
|
|
146
|
+
const result = installGraphify(cwd);
|
|
147
|
+
graphifyReady = result.available;
|
|
148
|
+
graphifyInstalled = result.installed;
|
|
149
|
+
if (!graphifyReady) {
|
|
150
|
+
console.warn(
|
|
151
|
+
"Graphify installation failed. Continue with manual setup later."
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (graphifyReady && !options.skipIndex) {
|
|
157
|
+
const graphConfigPath = path.join(t.config, "analyze.graphify.json");
|
|
158
|
+
runInitialGraphifyIndex(cwd, graphConfigPath);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const statePath = path.join(t.docflowRoot, "state.json");
|
|
162
|
+
const state = readJson(statePath, {});
|
|
163
|
+
state.graphify = {
|
|
164
|
+
ready: graphifyReady,
|
|
165
|
+
installedByInit: graphifyInstalled,
|
|
166
|
+
lastBootstrapAt: new Date().toISOString()
|
|
167
|
+
};
|
|
168
|
+
writeJson(statePath, state, { overwrite: true });
|
|
169
|
+
|
|
170
|
+
console.log("Spec Writer initialization complete.");
|
|
171
|
+
console.log("Next steps:");
|
|
172
|
+
console.log("- Run `/analyze [paths...]` in Cursor.");
|
|
173
|
+
console.log("- Run `/generate-srs` and `/generate-detail-design` incrementally.");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
module.exports = {
|
|
177
|
+
runInit
|
|
178
|
+
};
|