archscribe 0.2.0 → 0.2.2-rc.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 +1 -8
- package/dist/cli/archscribe.js +29 -74
- package/dist/cli/archscribe.js.map +1 -1
- package/dist/cli/doctor.js +1 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/login.js +5 -2
- package/dist/cli/login.js.map +1 -1
- package/dist/cli/rag.d.ts +4 -1
- package/dist/cli/rag.js +29 -7
- package/dist/cli/rag.js.map +1 -1
- package/dist/cli/run.js +7 -1
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/shell.d.ts +1 -1
- package/dist/cli/shell.js +29 -3
- package/dist/cli/shell.js.map +1 -1
- package/dist/core/docx-package.d.ts +9 -0
- package/dist/core/docx-package.js +99 -0
- package/dist/core/docx-package.js.map +1 -0
- package/dist/core/docx-styles.d.ts +12 -11
- package/dist/core/docx-styles.js +12 -11
- package/dist/core/docx-styles.js.map +1 -1
- package/dist/core/docx-update.d.ts +6 -0
- package/dist/core/docx-update.js +437 -0
- package/dist/core/docx-update.js.map +1 -0
- package/dist/core/docx.d.ts +8 -2
- package/dist/core/docx.js +263 -74
- package/dist/core/docx.js.map +1 -1
- package/dist/core/flow.js +8 -2
- package/dist/core/flow.js.map +1 -1
- package/dist/core/iuh-logo.d.ts +1 -0
- package/dist/core/iuh-logo.js +3 -0
- package/dist/core/iuh-logo.js.map +1 -0
- package/dist/core/manifest.js +1 -1
- package/dist/core/manifest.js.map +1 -1
- package/dist/core/markdown.js +24 -11
- package/dist/core/markdown.js.map +1 -1
- package/dist/core/parser.js +3 -0
- package/dist/core/parser.js.map +1 -1
- package/dist/core/project-config.d.ts +4 -0
- package/dist/core/project-config.js +39 -0
- package/dist/core/project-config.js.map +1 -1
- package/dist/diagrams/layout/radial.js +69 -0
- package/dist/diagrams/layout/radial.js.map +1 -1
- package/dist/evaluation/dashboard-review.js +66 -0
- package/dist/evaluation/dashboard-review.js.map +1 -1
- package/dist/knowledge/embedding.d.ts +11 -0
- package/dist/knowledge/embedding.js +31 -0
- package/dist/knowledge/embedding.js.map +1 -0
- package/dist/knowledge/hub-grouping.d.ts +3 -3
- package/dist/knowledge/hub-grouping.js +52 -54
- package/dist/knowledge/hub-grouping.js.map +1 -1
- package/dist/knowledge/qdrant-client.d.ts +20 -0
- package/dist/knowledge/qdrant-client.js +95 -0
- package/dist/knowledge/qdrant-client.js.map +1 -0
- package/dist/knowledge/rag-augment.d.ts +1 -1
- package/dist/knowledge/rag-augment.js +7 -6
- package/dist/knowledge/rag-augment.js.map +1 -1
- package/dist/knowledge/retriever.d.ts +2 -6
- package/dist/knowledge/retriever.js +14 -27
- package/dist/knowledge/retriever.js.map +1 -1
- package/dist/knowledge/seed-data-extended.d.ts +7 -0
- package/dist/knowledge/seed-data-extended.js +183 -0
- package/dist/knowledge/seed-data-extended.js.map +1 -0
- package/dist/knowledge/seed-data-extra.d.ts +6 -0
- package/dist/knowledge/seed-data-extra.js +178 -0
- package/dist/knowledge/seed-data-extra.js.map +1 -0
- package/dist/knowledge/seed-data.d.ts +3 -0
- package/dist/knowledge/seed-data.js +333 -0
- package/dist/knowledge/seed-data.js.map +1 -0
- package/dist/knowledge/seed.d.ts +22 -0
- package/dist/knowledge/seed.js +44 -0
- package/dist/knowledge/seed.js.map +1 -0
- package/dist/knowledge/types.d.ts +1 -4
- package/dist/license/banner.d.ts +3 -1
- package/dist/license/banner.js +6 -2
- package/dist/license/banner.js.map +1 -1
- package/dist/license/client.d.ts +7 -3
- package/dist/license/client.js +15 -2
- package/dist/license/client.js.map +1 -1
- package/dist/license/gate.d.ts +3 -1
- package/dist/license/gate.js +1 -1
- package/dist/license/gate.js.map +1 -1
- package/dist/parser.jar +0 -0
- package/dist/server.js +10 -28
- package/dist/server.js.map +1 -1
- package/dist/theory/fill.d.ts +3 -1
- package/dist/theory/fill.js +28 -47
- package/dist/theory/fill.js.map +1 -1
- package/dist/theory/references.d.ts +32 -5
- package/dist/theory/references.js +126 -2
- package/dist/theory/references.js.map +1 -1
- package/dist/theory/scaffold.js +7 -6
- package/dist/theory/scaffold.js.map +1 -1
- package/dist/tools/analyze_project.js +3 -0
- package/dist/tools/analyze_project.js.map +1 -1
- package/dist/tools/environment.js +1 -0
- package/dist/tools/environment.js.map +1 -1
- package/dist/tools/generate_report.d.ts +5 -5
- package/dist/tools/generate_report.js +83 -232
- package/dist/tools/generate_report.js.map +1 -1
- package/dist/tools/learn_usecase.d.ts +6 -2
- package/dist/tools/learn_usecase.js +34 -50
- package/dist/tools/learn_usecase.js.map +1 -1
- package/dist/tools/scaffold.js +24 -23
- package/dist/tools/scaffold.js.map +1 -1
- package/dist/types/license.d.ts +3 -1
- package/dist/types/report.d.ts +3 -3
- package/dist/types/theory.d.ts +4 -1
- package/dist/types/uc-grouping.d.ts +8 -0
- package/dist/utils/approval.d.ts +32 -4
- package/dist/utils/approval.js +160 -9
- package/dist/utils/approval.js.map +1 -1
- package/dist/utils/dashboard-launcher.js +1 -0
- package/dist/utils/dashboard-launcher.js.map +1 -1
- package/dist/utils/keep-regions.d.ts +44 -0
- package/dist/utils/keep-regions.js +153 -0
- package/dist/utils/keep-regions.js.map +1 -0
- package/package.json +10 -9
- package/dist/core/review-ledger.d.ts +0 -36
- package/dist/core/review-ledger.js +0 -104
- package/dist/core/review-ledger.js.map +0 -1
- package/dist/core/review-rerun.d.ts +0 -16
- package/dist/core/review-rerun.js +0 -31
- package/dist/core/review-rerun.js.map +0 -1
- package/dist/knowledge/local-kb.d.ts +0 -4
- package/dist/knowledge/local-kb.js +0 -82
- package/dist/knowledge/local-kb.js.map +0 -1
- package/dist/knowledge/rag-client.d.ts +0 -11
- package/dist/knowledge/rag-client.js +0 -60
- package/dist/knowledge/rag-client.js.map +0 -1
- package/dist/knowledge/rules.d.ts +0 -2
- package/dist/knowledge/rules.js +0 -10
- package/dist/knowledge/rules.js.map +0 -1
- package/dist/tools/review-tasks.d.ts +0 -28
- package/dist/tools/review-tasks.js +0 -168
- package/dist/tools/review-tasks.js.map +0 -1
- package/dist/utils/mcp-launch.d.ts +0 -24
- package/dist/utils/mcp-launch.js +0 -37
- package/dist/utils/mcp-launch.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/theory/scaffold.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/theory/scaffold.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,kFAAkF;AAClF,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC;A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AAC,qBAAqB;QACnD,KAAK;QACL,WAAW,EAAY,MAAM,CAAC,WAAW;QACzC,kBAAkB,EAAK,mBAAmB;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Used by the MCP analyze_project tool and the archscribe-docs skill.
|
|
4
4
|
*/
|
|
5
5
|
import path from "node:path";
|
|
6
|
+
import fs from "node:fs";
|
|
6
7
|
import { scanRepo, extractClasses, extractDependencies } from "./scan_repo.js";
|
|
7
8
|
import { generateReport } from "./generate_report.js";
|
|
8
9
|
// ── Implementation ────────────────────────────────────────────────────────────
|
|
@@ -18,9 +19,11 @@ export async function analyzeProject(input) {
|
|
|
18
19
|
const resolvedOutput = outputDir
|
|
19
20
|
? path.resolve(outputDir)
|
|
20
21
|
: path.resolve(projectPath, "archscribe-output");
|
|
22
|
+
fs.mkdirSync(resolvedOutput, { recursive: true });
|
|
21
23
|
const t0 = Date.now();
|
|
22
24
|
const ir = await scanRepo({
|
|
23
25
|
project_path: projectPath,
|
|
26
|
+
output_path: path.join(resolvedOutput, "ir.json"),
|
|
24
27
|
});
|
|
25
28
|
const parseTimeMs = Date.now() - t0;
|
|
26
29
|
const classes = extractClasses(ir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze_project.js","sourceRoot":"","sources":["../../src/tools/analyze_project.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"analyze_project.js","sourceRoot":"","sources":["../../src/tools/analyze_project.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAyBtD,iFAAiF;AAEj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AAI;QAC5B,SAAS,EAAE;YACT,UAAU,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;YACnC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC;SAC9C;QACD,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/tools/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAyB/C,iFAAiF;AAEjF,SAAS,QAAQ;IACf,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE;QACxC,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/tools/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAyB/C,iFAAiF;AAEjF,SAAS,QAAQ;IACf,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE;QACxC,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;QACjC,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,wBAAwB;YACh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D,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1F,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { DependencyEdge, IR } from "../types/ir.js";
|
|
2
2
|
import type { ClassExtractionResult, ExtractedClass } from "../types/diagram.js";
|
|
3
3
|
import type { ProjectInfo, ReportOutputs, UseCaseSelection } from "../types/report.js";
|
|
4
|
-
import
|
|
4
|
+
import { renderMarkdownToDocx } from "../core/docx.js";
|
|
5
5
|
import type { ApprovedHub } from "../types/uc-grouping.js";
|
|
6
6
|
export interface GenerateReportInput {
|
|
7
|
+
report_source?: string;
|
|
7
8
|
ir: IR;
|
|
8
9
|
classes?: ClassExtractionResult | ExtractedClass[];
|
|
9
10
|
dependencies?: DependencyEdge[];
|
|
@@ -25,8 +26,9 @@ export interface GenerateReportInput {
|
|
|
25
26
|
* Returns paths to all generated artifacts.
|
|
26
27
|
*/
|
|
27
28
|
export declare function generateReport(input: GenerateReportInput): Promise<ReportOutputs>;
|
|
28
|
-
export declare function assertReviewLicenseCeiling(check: LicenseCheckResult, retained: number, work: number): void;
|
|
29
29
|
export interface RenderReportDocxInput {
|
|
30
|
+
report_source?: string;
|
|
31
|
+
project_path?: string;
|
|
30
32
|
markdown_path: string;
|
|
31
33
|
output_path: string;
|
|
32
34
|
project_info?: ProjectInfo;
|
|
@@ -35,6 +37,4 @@ export interface RenderReportDocxInput {
|
|
|
35
37
|
* Re-render DOCX from an already-edited Markdown report.
|
|
36
38
|
* Useful after manual review edits to report.md.
|
|
37
39
|
*/
|
|
38
|
-
export declare function renderReportDocx(input: RenderReportDocxInput): Promise<
|
|
39
|
-
docx_path: string;
|
|
40
|
-
}>;
|
|
40
|
+
export declare function renderReportDocx(input: RenderReportDocxInput): Promise<Awaited<ReturnType<typeof renderMarkdownToDocx>>>;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
3
|
import { buildReportMarkdown } from "../core/markdown.js";
|
|
5
4
|
import { renderMarkdownToDocx } from "../core/docx.js";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { buildUseCaseCatalog, buildUseCaseFlows } from "../core/flow.js";
|
|
7
7
|
import { mergeUseCaseSelection, parseReviewNotesFile } from "./review.js";
|
|
8
8
|
import { loadLicense } from "../license/verify.js";
|
|
9
9
|
import { loadSession } from "../license/session.js";
|
|
10
10
|
import { runLicenseInfo } from "../license/run-license.js";
|
|
11
11
|
import { applyLicenseLimits, isProTier } from "../license/gate.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { loadReviewLedger } from "../core/review-ledger.js";
|
|
15
|
-
import { sourceKey, selectRerunWork } from "../core/review-rerun.js";
|
|
12
|
+
import { applyApprovedSpecSnapshots, approvedDiagramIds, prepareApprovalSnapshots, pruneApprovedSnapshots, restoreApprovedDiagrams, snapshotApprovedDiagrams } from "../utils/approval.js";
|
|
13
|
+
import { applyKeepRegions, extractKeepRegions, preserveFilledChapters } from "../utils/keep-regions.js";
|
|
16
14
|
import { writeActivityDiagrams } from "../diagrams/activity.js";
|
|
17
15
|
import { writeSequenceDiagrams } from "../diagrams/sequence.js";
|
|
18
16
|
import { writeUsecaseDiagrams } from "../diagrams/usecase.js";
|
|
@@ -32,7 +30,7 @@ import { isLoginUc, isRegisterUc } from "../diagrams/usecase_layout.js";
|
|
|
32
30
|
import { snapshotRun } from "../utils/run-history.js";
|
|
33
31
|
import { clearDrawioDir } from "../utils/diagram-dir.js";
|
|
34
32
|
import { getPackageVersion } from "../utils/version.js";
|
|
35
|
-
import { buildManifest, writeManifest
|
|
33
|
+
import { buildManifest, writeManifest } from "../core/manifest.js";
|
|
36
34
|
/** Only DI edges (field_injection + constructor_injection) match the dependency ground-truth methodology. */
|
|
37
35
|
const INJECTION_TYPES = new Set(["field_injection", "constructor_injection"]);
|
|
38
36
|
/** Only core Spring domain stereotypes match the class-count ground-truth methodology. */
|
|
@@ -64,180 +62,39 @@ function normalizeClasses(raw) {
|
|
|
64
62
|
* Returns paths to all generated artifacts.
|
|
65
63
|
*/
|
|
66
64
|
export async function generateReport(input) {
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
fs.cpSync(publishedDir, outputDir, { recursive: true });
|
|
73
|
-
else
|
|
74
|
-
ensureDir(outputDir);
|
|
75
|
-
const result = await generateStagedReport(input, outputDir);
|
|
76
|
-
if (!result.docx_path)
|
|
77
|
-
fs.rmSync(path.join(outputDir, 'report.docx'), { force: true });
|
|
78
|
-
const backup = `${publishedDir}.previous-${randomUUID()}`;
|
|
79
|
-
const hadPrevious = fs.existsSync(publishedDir);
|
|
80
|
-
if (hadPrevious)
|
|
81
|
-
fs.renameSync(publishedDir, backup);
|
|
82
|
-
try {
|
|
83
|
-
fs.renameSync(outputDir, publishedDir);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
if (hadPrevious)
|
|
87
|
-
fs.renameSync(backup, publishedDir);
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
if (hadPrevious) {
|
|
91
|
-
try {
|
|
92
|
-
fs.rmSync(backup, { recursive: true, force: true });
|
|
93
|
-
}
|
|
94
|
-
catch { /* a completed publication must not be reported as failed due to backup cleanup */ }
|
|
95
|
-
}
|
|
96
|
-
const published = (file) => file?.replace(outputDir + path.sep, publishedDir + path.sep);
|
|
97
|
-
if (process.env.ARCHSCRIBE_RESEARCH_MODE !== '1') {
|
|
98
|
-
try {
|
|
99
|
-
const evalReport = JSON.parse(fs.readFileSync(path.join(publishedDir, 'evaluation-report.json'), 'utf8'));
|
|
100
|
-
notifyNewReport(input.ir.project.projectPath, evalReport).catch(() => { });
|
|
101
|
-
recordPipelineComplete({
|
|
102
|
-
ucCount: result.usecase_selected_count,
|
|
103
|
-
diagramTypes: ['usecase', ...(result.class_diagram_path ? ['class'] : []),
|
|
104
|
-
...(result.architecture_diagram_path ? ['architecture'] : []),
|
|
105
|
-
...(result.activity_diagram_paths?.length ? ['activity'] : []),
|
|
106
|
-
...(result.sequence_diagram_paths?.length ? ['sequence'] : [])],
|
|
107
|
-
processingMs: evalReport.timing.totalTimeMs,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
catch { /* a published report remains successful if optional notifications fail */ }
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
...result, markdown_path: published(result.markdown_path), docx_path: published(result.docx_path),
|
|
114
|
-
review_notes_path: published(result.review_notes_path),
|
|
115
|
-
architecture_diagram_path: published(result.architecture_diagram_path),
|
|
116
|
-
usecase_diagram_path: published(result.usecase_diagram_path),
|
|
117
|
-
class_diagram_path: published(result.class_diagram_path),
|
|
118
|
-
activity_diagram_paths: result.activity_diagram_paths?.map((p) => published(p)),
|
|
119
|
-
sequence_diagram_paths: result.sequence_diagram_paths?.map((p) => published(p)),
|
|
120
|
-
evaluation_report_path: published(result.evaluation_report_path), dashboard_path: published(result.dashboard_path),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
if (fs.existsSync(outputDir))
|
|
125
|
-
fs.rmSync(outputDir, { recursive: true, force: true });
|
|
65
|
+
const { resolveReportSource } = await import("../core/project-config.js");
|
|
66
|
+
const reportSource = resolveReportSource(input.ir.project.projectPath, input.report_source);
|
|
67
|
+
if (reportSource) {
|
|
68
|
+
const { validateManagedSource } = await import("../core/docx-update.js");
|
|
69
|
+
await validateManagedSource(fs.readFileSync(reportSource));
|
|
126
70
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
throw new Error('License UC ceiling: retained approvals and requested work exceed this tier; reduce work or upgrade.');
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
async function generateStagedReport(input, outputDir) {
|
|
134
|
-
const previousManifestPath = path.join(outputDir, 'manifest.json');
|
|
135
|
-
const previousManifest = fs.existsSync(previousManifestPath) ? JSON.parse(fs.readFileSync(previousManifestPath, 'utf8')) : null;
|
|
71
|
+
const outputDirInput = input.output_dir ?? path.join(input.ir.project.projectPath, "archscribe-output");
|
|
72
|
+
const outputDir = resolveWorkspacePath(outputDirInput);
|
|
73
|
+
ensureDir(outputDir);
|
|
136
74
|
const timer = new PipelineTimer();
|
|
137
75
|
timer.recordSplit("parse", input.parse_time_ms ?? 0);
|
|
76
|
+
// Export IR to disk so get_client_theory_scaffold and token-savings can read it
|
|
77
|
+
const irJsonPath = path.join(outputDir, "ir.json");
|
|
78
|
+
fs.writeFileSync(irJsonPath, JSON.stringify(minifyIr(input.ir), null, 2), "utf8");
|
|
138
79
|
const classResult = normalizeClasses(input.classes);
|
|
139
80
|
const dependencies = input.dependencies ?? [];
|
|
140
81
|
// ── Review + selection ───────────────────────────────────────────────────
|
|
141
82
|
const reviewPath = input.review_notes_path ? resolveWorkspacePath(input.review_notes_path) : undefined;
|
|
142
83
|
const reviewSelection = parseReviewNotesFile(reviewPath);
|
|
143
84
|
const usecaseSelection = mergeUseCaseSelection(input.usecase_selection, reviewSelection) ?? { limit: 8 };
|
|
144
|
-
const requestedSelection = { ...usecaseSelection };
|
|
145
85
|
// ── License gate ─────────────────────────────────────────────────────────
|
|
146
86
|
const licenseCheck = await loadLicense([input.ir.project.projectPath]);
|
|
147
87
|
const gateResult = applyLicenseLimits(licenseCheck, usecaseSelection);
|
|
148
88
|
// ── UC flows ─────────────────────────────────────────────────────────────
|
|
149
89
|
timer.start("flow");
|
|
150
90
|
const catalog = buildUseCaseCatalog(input.ir);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// A new comment/draft does not revoke the last human-approved version.
|
|
157
|
-
const frozen = (key) => !!ledger.entries[key]?.snapshots?.spec && ledger.entries[key]?.status !== 'pending';
|
|
158
|
-
const approvedKeys = new Set(Object.values(ledger.entries).filter((e) => frozen(e.key)).map((e) => e.key));
|
|
159
|
-
const explicit = new Set();
|
|
160
|
-
const hasExplicit = !!(requestedSelection.selected_ids?.length || requestedSelection.selected_titles?.length || requestedSelection.selected_endpoints?.length);
|
|
161
|
-
for (const c of catalog) {
|
|
162
|
-
if (requestedSelection.selected_ids?.some((id) => id.toUpperCase() === c.id.toUpperCase()) ||
|
|
163
|
-
requestedSelection.selected_titles?.some((title) => c.title.toLowerCase().includes(title.trim().toLowerCase())) ||
|
|
164
|
-
requestedSelection.selected_endpoints?.some((endpoint) => c.endpoint.toLowerCase() === endpoint.trim().toLowerCase())) {
|
|
165
|
-
explicit.add(sourceKey({ endpoint: c.endpoint, sourceFile: c.sourceFile, controllerName: c.controller, methodName: c.methodName }));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
const unmatched = requestedSelection.selected_ids?.filter((id) => !catalog.some((c) => c.id.toUpperCase() === id.toUpperCase())) ?? [];
|
|
169
|
-
if (unmatched.length)
|
|
170
|
-
throw new Error(`Unmatched legacy use case ID(s): ${unmatched.join(', ')}; reconcile by endpoint before rerunning.`);
|
|
171
|
-
if (hasExplicit && !explicit.size)
|
|
172
|
-
throw new Error('Requested use cases did not match any current source; reconcile the selection before rerunning.');
|
|
173
|
-
const chosen = selectRerunWork(candidates, approvedKeys, usecaseSelection.limit ?? 8, hasExplicit ? explicit : undefined);
|
|
174
|
-
assertReviewLicenseCeiling(licenseCheck, chosen.retainedKeys.length, chosen.workKeys.length);
|
|
175
|
-
// Only write staged files once identity/ledger/license checks have succeeded.
|
|
176
|
-
const irJsonPath = path.join(outputDir, 'ir.json');
|
|
177
|
-
fs.writeFileSync(irJsonPath, JSON.stringify(minifyIr(input.ir), null, 2), 'utf8');
|
|
178
|
-
writeManifest(outputDir, buildManifest(input.ir, getPackageVersion()));
|
|
179
|
-
const selected = [...chosen.retainedKeys, ...chosen.workKeys];
|
|
180
|
-
const currentIds = candidates.filter((c) => selected.includes(c.key)).map((c) => c.id);
|
|
181
|
-
const usecaseFlows = currentIds.length ? buildUseCaseFlows(input.ir, { selected_ids: currentIds }, isProTier(licenseCheck) ? "pro" : "baseline") : [];
|
|
182
|
-
const byKey = new Map(usecaseFlows.map((f) => [sourceKey(f), f]));
|
|
183
|
-
const effectiveFlows = selected.filter((key) => byKey.has(key)).map((key) => {
|
|
184
|
-
const flow = byKey.get(key);
|
|
185
|
-
if (!flow)
|
|
186
|
-
throw new Error(`Missing selected use case: ${key}`);
|
|
187
|
-
return flow;
|
|
188
|
-
});
|
|
189
|
-
for (const key of chosen.unresolvedKeys) {
|
|
190
|
-
const entry = ledger.entries[key];
|
|
191
|
-
const [endpoint, sourceFile, controllerName, methodName] = JSON.parse(key);
|
|
192
|
-
effectiveFlows.splice(chosen.retainedKeys.indexOf(key), 0, { id: '', title: entry.title ?? methodName, endpoint, controllerName, methodName,
|
|
193
|
-
actor: '', purpose: '', description: 'Nguồn không còn trong lần quét hiện tại; giữ bản đã duyệt để đối chiếu.',
|
|
194
|
-
preconditions: [], successPostconditions: [], failurePostconditions: [], mainSteps: [], alternateFlows: [],
|
|
195
|
-
tier: 'baseline', sequenceSteps: [], sourceTrace: [`${sourceFile} -> ${controllerName}.${methodName}`] });
|
|
196
|
-
}
|
|
197
|
-
// Preserve the display ID in a frozen section; new work receives a unique ID if ranks shifted.
|
|
198
|
-
const usedIds = new Set();
|
|
199
|
-
for (const flow of effectiveFlows) {
|
|
200
|
-
const entry = ledger.entries[sourceKey(flow)];
|
|
201
|
-
if (frozen(sourceKey(flow))) {
|
|
202
|
-
const spec = fs.readFileSync(path.join(projectRoot, '.archscribe', entry.snapshots.spec), 'utf8');
|
|
203
|
-
flow.id = /^\*\*(UC\d+)\s+-\s+/m.exec(spec)?.[1] ?? flow.id;
|
|
204
|
-
if (!flow.id)
|
|
205
|
-
throw new Error('Approved spec has no use case ID');
|
|
206
|
-
if (usedIds.has(flow.id))
|
|
207
|
-
throw new Error(`Approved use cases share display ID ${flow.id}; reconcile before rerunning.`);
|
|
208
|
-
usedIds.add(flow.id);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
let nextId = catalog.length + 1;
|
|
212
|
-
for (const flow of effectiveFlows)
|
|
213
|
-
if (!frozen(sourceKey(flow))) {
|
|
214
|
-
if (usedIds.has(flow.id)) {
|
|
215
|
-
do {
|
|
216
|
-
flow.id = `UC${String(nextId++).padStart(3, '0')}`;
|
|
217
|
-
} while (usedIds.has(flow.id));
|
|
218
|
-
}
|
|
219
|
-
usedIds.add(flow.id);
|
|
220
|
-
}
|
|
221
|
-
usecaseFlows.length = 0;
|
|
222
|
-
usecaseFlows.push(...effectiveFlows);
|
|
223
|
-
const changedApproved = [];
|
|
224
|
-
for (const flow of usecaseFlows) {
|
|
225
|
-
const entry = ledger.entries[sourceKey(flow)];
|
|
226
|
-
if (!frozen(sourceKey(flow)) || !entry || !byKey.has(entry.key))
|
|
227
|
-
continue;
|
|
228
|
-
const current = catalog.find((c) => candidates.find((x) => x.id === c.id)?.key === entry.key);
|
|
229
|
-
if (current && entry.title && entry.title !== current.title)
|
|
230
|
-
changedApproved.push(flow.endpoint);
|
|
231
|
-
const relative = flow.sourceTrace[0]?.split(' -> ')[0]?.replace(/\\/g, '/');
|
|
232
|
-
const projectRelative = relative && path.posix.join(previousManifest?.sourceRoot ?? input.ir.project.sourceRoot, relative);
|
|
233
|
-
const before = entry.sourceFingerprint ?? (projectRelative && previousManifest?.files[projectRelative]);
|
|
234
|
-
const absolute = projectRelative && path.join(projectRoot, projectRelative);
|
|
235
|
-
if (before && absolute && fs.existsSync(absolute) && before !== sha256File(absolute)) {
|
|
236
|
-
changedApproved.push(flow.endpoint);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
91
|
+
// Drop snapshots for use cases this project no longer has, before anything
|
|
92
|
+
// reads them (ids are positional, so a deleted endpoint leaves them behind).
|
|
93
|
+
pruneApprovedSnapshots(outputDir, usecaseSelection, catalog.map((c) => c.id));
|
|
94
|
+
const approvalSnapshots = prepareApprovalSnapshots(outputDir, usecaseSelection, catalog.map((c) => ({ id: c.id, endpoint: c.endpoint })));
|
|
95
|
+
const usecaseFlows = buildUseCaseFlows(input.ir, usecaseSelection, isProTier(licenseCheck) ? "pro" : "baseline");
|
|
239
96
|
// RAG augmentation (no-op when ARCHSCRIBE_ENABLE_RAG unset or ARCHSCRIBE_RESEARCH_MODE=1)
|
|
240
|
-
await augmentFlowsWithRAG(usecaseFlows
|
|
97
|
+
await augmentFlowsWithRAG(usecaseFlows);
|
|
241
98
|
// Apply actor overrides (Pro only — gateResult.blockActorOverrides=true for free)
|
|
242
99
|
const effectiveOverrides = gateResult.blockActorOverrides ? undefined : input.actor_overrides;
|
|
243
100
|
if (effectiveOverrides) {
|
|
@@ -299,43 +156,21 @@ async function generateStagedReport(input, outputDir) {
|
|
|
299
156
|
// computeCompleteness() counts them (coverage/score above 100%).
|
|
300
157
|
clearDrawioDir(activityDir);
|
|
301
158
|
clearDrawioDir(sequenceDir);
|
|
159
|
+
// Restore approved diagrams from approved/diagrams/ before rendering.
|
|
160
|
+
// This prevents regeneration of approved files even if review-notes was reset.
|
|
161
|
+
const { restoredActivityIds, restoredSequenceIds } = restoreApprovedDiagrams(approvalSnapshots.approvedDir, activityDir, sequenceDir);
|
|
302
162
|
let activityPaths;
|
|
303
163
|
let sequencePaths;
|
|
304
164
|
let usecaseDiagramPath;
|
|
305
165
|
let classDiagramPath;
|
|
306
166
|
let architectureDiagramPath;
|
|
307
167
|
try {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
writeSequenceDiagrams(newFlows, sequenceDir);
|
|
311
|
-
for (const flow of usecaseFlows) {
|
|
312
|
-
const entry = ledger.entries[sourceKey(flow)];
|
|
313
|
-
if (!frozen(sourceKey(flow)))
|
|
314
|
-
continue;
|
|
315
|
-
for (const kind of ['activity', 'sequence']) {
|
|
316
|
-
const snapshot = entry.snapshots?.[kind];
|
|
317
|
-
if (!snapshot)
|
|
318
|
-
continue;
|
|
319
|
-
const spec = fs.readFileSync(path.join(projectRoot, '.archscribe', entry.snapshots.spec), 'utf8');
|
|
320
|
-
const figure = new RegExp(`<!-- FIGURE: diagrams/${kind}/([^\\s"/\\\\]+\\.drawio)`).exec(spec)?.[1];
|
|
321
|
-
const dest = path.join(kind === 'activity' ? activityDir : sequenceDir, figure ?? `${flow.id}_${kind}.drawio`);
|
|
322
|
-
fs.copyFileSync(path.join(projectRoot, '.archscribe', snapshot), dest);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
const activityByFlow = usecaseFlows.map((f) => {
|
|
326
|
-
const file = fs.readdirSync(activityDir).find((name) => name.startsWith(`${f.id}_`) && name.endsWith('.drawio'));
|
|
327
|
-
return file ? path.join(activityDir, file) : undefined;
|
|
328
|
-
});
|
|
329
|
-
activityByFlow.forEach((p, i) => { if (p)
|
|
168
|
+
activityPaths = writeActivityDiagrams(usecaseFlows, activityDir, approvalSnapshots.approvedIds, restoredActivityIds);
|
|
169
|
+
activityPaths.forEach((p, i) => { if (usecaseFlows[i])
|
|
330
170
|
usecaseFlows[i].activityDiagramPath = path.relative(outputDir, p); });
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
return file ? path.join(sequenceDir, file) : undefined;
|
|
334
|
-
});
|
|
335
|
-
sequenceByFlow.forEach((p, i) => { if (p)
|
|
171
|
+
sequencePaths = writeSequenceDiagrams(usecaseFlows, sequenceDir, approvalSnapshots.approvedIds, restoredSequenceIds);
|
|
172
|
+
sequencePaths.forEach((p, i) => { if (usecaseFlows[i])
|
|
336
173
|
usecaseFlows[i].sequenceDiagramPath = path.relative(outputDir, p); });
|
|
337
|
-
activityPaths = activityByFlow.filter((p) => !!p);
|
|
338
|
-
sequencePaths = sequenceByFlow.filter((p) => !!p);
|
|
339
174
|
const usecasePaths = await writeUsecaseDiagrams(usecaseFlows, catalog, diagramsDir);
|
|
340
175
|
usecaseDiagramPath = usecasePaths[0] ?? path.join(diagramsDir, "usecase-guest-customer.drawio");
|
|
341
176
|
if (!usecaseSelection.disablePremiumDiagrams) {
|
|
@@ -344,6 +179,9 @@ async function generateStagedReport(input, outputDir) {
|
|
|
344
179
|
architectureDiagramPath = path.join(diagramsDir, "architecture.drawio");
|
|
345
180
|
writeArchitectureDiagram(input.ir, architectureDiagramPath);
|
|
346
181
|
}
|
|
182
|
+
// Persist approved diagrams to approved/diagrams/ so they survive review-notes resets.
|
|
183
|
+
const { activity: approvedActivityIds, sequence: approvedSequenceIds } = approvedDiagramIds(usecaseFlows.map((f) => f.id), approvalSnapshots.approvedIds ?? [], usecaseSelection.approved_activity_ids ?? [], usecaseSelection.approved_sequence_ids ?? []);
|
|
184
|
+
snapshotApprovedDiagrams(approvalSnapshots.approvedDir, activityDir, sequenceDir, approvedActivityIds, approvedSequenceIds);
|
|
347
185
|
timer.stop("diagram");
|
|
348
186
|
}
|
|
349
187
|
finally {
|
|
@@ -358,43 +196,23 @@ async function generateStagedReport(input, outputDir) {
|
|
|
358
196
|
...(classDiagramPath ? { class: path.relative(outputDir, classDiagramPath) } : {}),
|
|
359
197
|
...(architectureDiagramPath ? { architecture: path.relative(outputDir, architectureDiagramPath) } : {}),
|
|
360
198
|
});
|
|
361
|
-
|
|
362
|
-
const entry = ledger.entries[sourceKey(flow)];
|
|
363
|
-
if (!frozen(sourceKey(flow)))
|
|
364
|
-
continue;
|
|
365
|
-
const section = fs.readFileSync(path.join(projectRoot, '.archscribe', entry.snapshots.spec), 'utf8');
|
|
366
|
-
const generated = extractUseCaseSection(report.markdown, flow.id);
|
|
367
|
-
if (!generated)
|
|
368
|
-
throw new Error(`Missing generated section: ${flow.id}`);
|
|
369
|
-
report.markdown = report.markdown.replace(generated.trimEnd(), section.trimEnd());
|
|
370
|
-
}
|
|
371
|
-
if (chosen.unresolvedKeys.length) {
|
|
372
|
-
const warning = `\n**Cần đối chiếu:** ${chosen.unresolvedKeys.length} use case đã duyệt nhưng nguồn không còn trong lần quét hiện tại; bản lưu được giữ nguyên.\n`;
|
|
373
|
-
report.markdown = report.markdown.replace('#### 3.1.4 Đặc tả một số use case', `${warning}\n#### 3.1.4 Đặc tả một số use case`);
|
|
374
|
-
}
|
|
375
|
-
if (changedApproved.length) {
|
|
376
|
-
const warning = `\n**Cần đối chiếu:** Nguồn đã thay đổi cho use case đã duyệt: ${[...new Set(changedApproved)].join(', ')}. Đặc tả và sơ đồ vẫn là bản lưu, cần duyệt lại.\n`;
|
|
377
|
-
report.markdown = report.markdown.replace('#### 3.1.4 Đặc tả một số use case', `${warning}\n#### 3.1.4 Đặc tả một số use case`);
|
|
378
|
-
}
|
|
379
|
-
const previousMd = path.join(outputDir, 'report.md');
|
|
380
|
-
if (fs.existsSync(previousMd)) {
|
|
381
|
-
const old = fs.readFileSync(previousMd, 'utf8');
|
|
382
|
-
for (const chapter of [1, 2, 4, 5]) {
|
|
383
|
-
const re = new RegExp(`(^## CHƯƠNG ${chapter}:.*?)(?=^## CHƯƠNG \\d+:|^## TÀI LIỆU THAM KHẢO|$(?![\\s\\S]))`, 'ms');
|
|
384
|
-
const match = old.match(re);
|
|
385
|
-
if (match && match[1].trim().split(/\r?\n/).length > 4)
|
|
386
|
-
report.markdown = report.markdown.replace(re, match[1]);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
199
|
+
report.markdown = applyApprovedSpecSnapshots(report.markdown, approvalSnapshots);
|
|
389
200
|
const markdownPath = path.join(outputDir, "report.md");
|
|
390
|
-
const docxPath = path.join(outputDir, "report.docx");
|
|
201
|
+
const docxPath = path.join(outputDir, reportSource ? `report-updated-${randomUUID()}.docx` : "report.docx");
|
|
391
202
|
const reviewNotesPath = path.join(outputDir, "review-notes.md");
|
|
203
|
+
// The report is rebuilt from scratch, so put back what the previous run must
|
|
204
|
+
// not lose: the theory chapters write_theory_content filled (the generator
|
|
205
|
+
// only emits skeletons for them), and anything the user or an AI wrapped in
|
|
206
|
+
// archscribe:keep markers.
|
|
207
|
+
const previousMarkdown = fs.existsSync(markdownPath) ? fs.readFileSync(markdownPath, "utf8") : "";
|
|
208
|
+
report.markdown = preserveFilledChapters(report.markdown, previousMarkdown);
|
|
209
|
+
report.markdown = applyKeepRegions(report.markdown, extractKeepRegions(previousMarkdown));
|
|
392
210
|
fs.writeFileSync(markdownPath, report.markdown, "utf8");
|
|
393
|
-
|
|
394
|
-
fs.writeFileSync(reviewNotesPath, report.reviewNotes, "utf8");
|
|
211
|
+
fs.writeFileSync(reviewNotesPath, report.reviewNotes, "utf8");
|
|
395
212
|
let docxWritten = false;
|
|
213
|
+
let docxResult;
|
|
396
214
|
if (!usecaseSelection.disableDocx) {
|
|
397
|
-
await renderMarkdownToDocx(report.markdown, docxPath, input.project_info);
|
|
215
|
+
docxResult = await renderMarkdownToDocx(report.markdown, docxPath, input.project_info, outputDir, { reportSource });
|
|
398
216
|
docxWritten = true;
|
|
399
217
|
}
|
|
400
218
|
timer.stop("report");
|
|
@@ -424,7 +242,6 @@ async function generateStagedReport(input, outputDir) {
|
|
|
424
242
|
...(architectureDiagramPath ? { architecture: toUrlPath(path.relative(outputDir, architectureDiagramPath)) } : {}),
|
|
425
243
|
},
|
|
426
244
|
});
|
|
427
|
-
// Paths are relative; the run's staged absolute directory must not escape into published JSON.
|
|
428
245
|
const evaluationReportPath = path.join(outputDir, "evaluation-report.json");
|
|
429
246
|
const dashboardPath = path.join(outputDir, "dashboard.html");
|
|
430
247
|
fs.writeFileSync(evaluationReportPath, JSON.stringify(evalReport, null, 2), "utf8");
|
|
@@ -444,10 +261,36 @@ async function generateStagedReport(input, outputDir) {
|
|
|
444
261
|
generateDashboard(evalReport, dashboardPath);
|
|
445
262
|
// Notify centralized dashboard server (non-blocking, silent fail).
|
|
446
263
|
// Guarded by ARCHSCRIBE_RESEARCH_MODE so benchmark/thesis runs are unaffected.
|
|
447
|
-
|
|
264
|
+
if (process.env.ARCHSCRIBE_RESEARCH_MODE !== "1") {
|
|
265
|
+
notifyNewReport(input.ir.project.projectPath, evalReport).catch(() => {
|
|
266
|
+
// intentionally silent — dashboard is best-effort
|
|
267
|
+
});
|
|
268
|
+
// Fire-and-forget telemetry — this is the MCP tool path (Claude Code's
|
|
269
|
+
// scaffold_integration wires generate_report as the real entry point for
|
|
270
|
+
// most users), distinct from the CLI path's own call in cli/run.ts.
|
|
271
|
+
// Silently skipped when there's no license session or ARCHSCRIBE_TELEMETRY=0.
|
|
272
|
+
recordPipelineComplete({
|
|
273
|
+
ucCount: usecaseFlows.length,
|
|
274
|
+
diagramTypes: [
|
|
275
|
+
"usecase",
|
|
276
|
+
...(classDiagramPath ? ["class"] : []),
|
|
277
|
+
...(architectureDiagramPath ? ["architecture"] : []),
|
|
278
|
+
...(activityPaths.length ? ["activity"] : []),
|
|
279
|
+
...(sequencePaths.length ? ["sequence"] : []),
|
|
280
|
+
],
|
|
281
|
+
processingMs: timer.toMetrics().totalTimeMs,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
// Written LAST: `archscribe status` reads this, so it must describe a complete
|
|
285
|
+
// output. Written before the diagrams and the report, a run that crashed
|
|
286
|
+
// half-way still reported "fresh" — and the previous diagrams were already
|
|
287
|
+
// deleted by then.
|
|
288
|
+
writeManifest(outputDir, buildManifest(input.ir, getPackageVersion()));
|
|
448
289
|
return {
|
|
449
290
|
markdown_path: markdownPath,
|
|
450
291
|
docx_path: docxWritten ? docxPath : undefined, // undefined for free tier — no file was written
|
|
292
|
+
source_path: docxResult?.source_path,
|
|
293
|
+
updated_regions: docxResult?.updated_regions,
|
|
451
294
|
review_notes_path: reviewNotesPath,
|
|
452
295
|
architecture_diagram_path: architectureDiagramPath, // undefined for free tier
|
|
453
296
|
usecase_diagram_path: usecaseDiagramPath,
|
|
@@ -475,16 +318,24 @@ async function generateStagedReport(input, outputDir) {
|
|
|
475
318
|
export async function renderReportDocx(input) {
|
|
476
319
|
const mdPath = resolveWorkspacePath(input.markdown_path);
|
|
477
320
|
const outPath = resolveWorkspacePath(input.output_path);
|
|
478
|
-
|
|
321
|
+
const { resolveReportSource } = await import("../core/project-config.js");
|
|
322
|
+
const reportSource = input.project_path
|
|
323
|
+
? resolveReportSource(resolveWorkspacePath(input.project_path), input.report_source)
|
|
324
|
+
: input.report_source === undefined ? undefined : resolveReportSource(path.dirname(mdPath), input.report_source);
|
|
325
|
+
// DOCX export is Pro-only (FREE_DEFAULTS.exportDocx). This path used to write
|
|
326
|
+
// a watermarked file instead, so a Free user could still get a DOCX by hand
|
|
327
|
+
// — the same leak as write_theory_content, which wrote one with no banner.
|
|
479
328
|
const licCheck = await loadLicense([
|
|
480
329
|
path.dirname(mdPath),
|
|
481
330
|
path.dirname(path.dirname(mdPath)), // project root (one level above archscribe-output/)
|
|
482
331
|
]);
|
|
483
|
-
let markdown = fs.readFileSync(mdPath, "utf8");
|
|
484
332
|
if (licCheck.tier === "free") {
|
|
485
|
-
|
|
333
|
+
throw new Error("DOCX export cần bản Pro (hiện tại: Free). Xuất PDF/Markdown hoặc nâng cấp lên Pro.");
|
|
334
|
+
}
|
|
335
|
+
const markdown = fs.readFileSync(mdPath, "utf8");
|
|
336
|
+
if (!input.project_path && input.report_source === undefined) {
|
|
337
|
+
throw new Error("project_path is required to establish report source policy; alternatively select report_source explicitly");
|
|
486
338
|
}
|
|
487
|
-
|
|
488
|
-
return { docx_path: outPath };
|
|
339
|
+
return renderMarkdownToDocx(markdown, outPath, input.project_info, path.dirname(mdPath), { reportSource });
|
|
489
340
|
}
|
|
490
341
|
//# sourceMappingURL=generate_report.js.map
|