musubix2 0.5.48 → 0.5.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/.musubix-managed +1 -1
- package/dist/assets/skills-manifest.json +1 -1
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +104 -18
- package/dist/cli.js.map +1 -1
- package/dist/index.js +103 -18
- package/package.json +1 -1
package/.claude/.musubix-managed
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"generator":"musubix2","version":"0.5.
|
|
1
|
+
{"generator":"musubix2","version":"0.5.50","timestamp":"2026-07-10T06:43:13.120Z"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -83,6 +83,18 @@ interface CodeTraceData {
|
|
|
83
83
|
* "covered" when at least one source file references it.
|
|
84
84
|
*/
|
|
85
85
|
export declare function buildCodeTraceData(specsFile: string, srcDir: string): CodeTraceData;
|
|
86
|
+
/**
|
|
87
|
+
* Build symbol-level traceability links for impact analysis: each requirement
|
|
88
|
+
* is linked to the specific class/function that implements it (resolved from a
|
|
89
|
+
* preceding `// Implements: REQ-…` comment or an in-body reference), rather than
|
|
90
|
+
* to the whole file. This stops requirements that merely share a file from being
|
|
91
|
+
* reported as impacting one another. Falls back to a file-level link when no
|
|
92
|
+
* enclosing symbol can be resolved.
|
|
93
|
+
*/
|
|
94
|
+
export declare function buildSymbolTraceLinks(specsFile: string, srcDir: string): Array<{
|
|
95
|
+
source: string;
|
|
96
|
+
target: string;
|
|
97
|
+
}>;
|
|
86
98
|
export declare function handleTrace(sub: string | undefined, args: string[], flags?: Record<string, unknown>): Promise<ExitCodeValue>;
|
|
87
99
|
export declare function handleTraceVerify(flags?: Record<string, unknown>): Promise<ExitCodeValue>;
|
|
88
100
|
export declare function handlePolicy(sub: string | undefined, args: string[]): Promise<ExitCodeValue>;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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markdown_ears_parser = __esm({
|
|
|
1192
1192
|
"../core/dist/validators/markdown-ears-parser.js"() {
|
|
1193
1193
|
"use strict";
|
|
1194
1194
|
init_ears_validator();
|
|
1195
|
-
REQ_HEADING_REGEX = /^#{1,4}\s+(REQ-[A-Z]{
|
|
1195
|
+
REQ_HEADING_REGEX = /^#{1,4}\s+(REQ-[A-Z]{2,6}-\d{3}):\s*(.*)$/;
|
|
1196
1196
|
FIELD_REGEX = {
|
|
1197
1197
|
type: /^\*\*種別\*\*:\s*(.+)$/m,
|
|
1198
1198
|
priority: /^\*\*優先度\*\*:\s*(P[012])$/m,
|
|
@@ -15036,7 +15036,7 @@ function sddCoreTools() {
|
|
|
15036
15036
|
try {
|
|
15037
15037
|
const reqIds = [...new Set(params["requirementIds"] ?? [])];
|
|
15038
15038
|
const sources = params["sources"] ?? [];
|
|
15039
|
-
const refRe = /REQ-[A-Z]{
|
|
15039
|
+
const refRe = /REQ-[A-Z]{2,6}-\d{3}/g;
|
|
15040
15040
|
const covered = /* @__PURE__ */ new Set();
|
|
15041
15041
|
for (const s of sources) {
|
|
15042
15042
|
for (const m of (s.code ?? "").matchAll(refRe)) {
|
|
@@ -17072,13 +17072,13 @@ async function handleInit(targetPath = ".", name, force) {
|
|
|
17072
17072
|
}
|
|
17073
17073
|
return ExitCode.SUCCESS;
|
|
17074
17074
|
}
|
|
17075
|
-
var REQ_ID_RE = /REQ-[A-Z]{
|
|
17075
|
+
var REQ_ID_RE = /REQ-[A-Z]{2,6}-\d{3}/g;
|
|
17076
17076
|
function buildCodeTraceData(specsFile, srcDir) {
|
|
17077
17077
|
const reqIds = [];
|
|
17078
17078
|
if (existsSync11(specsFile)) {
|
|
17079
17079
|
const content = readFileSync6(specsFile, "utf-8");
|
|
17080
17080
|
for (const line of content.split("\n")) {
|
|
17081
|
-
const m = line.match(/^#{1,4}\s+(REQ-[A-Z]{
|
|
17081
|
+
const m = line.match(/^#{1,4}\s+(REQ-[A-Z]{2,6}-\d{3})\b/);
|
|
17082
17082
|
if (m) {
|
|
17083
17083
|
reqIds.push(m[1]);
|
|
17084
17084
|
}
|
|
@@ -17119,6 +17119,65 @@ function buildCodeTraceData(specsFile, srcDir) {
|
|
|
17119
17119
|
}
|
|
17120
17120
|
return { requirementIds, fileIds: [...fileSet].sort(), links, refsByReq };
|
|
17121
17121
|
}
|
|
17122
|
+
var DECL_RE = /(?:export\s+)?(?:default\s+)?(?:abstract\s+)?(?:class|interface|enum)\s+([A-Za-z_$][\w$]*)|(?:export\s+)?(?:default\s+)?(?:async\s+)?function\s*\*?\s+([A-Za-z_$][\w$]*)|(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:async\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/;
|
|
17123
|
+
function buildSymbolTraceLinks(specsFile, srcDir) {
|
|
17124
|
+
const reqSet = new Set(buildCodeTraceData(specsFile, srcDir).requirementIds);
|
|
17125
|
+
if (reqSet.size === 0 || !existsSync11(srcDir)) {
|
|
17126
|
+
return [];
|
|
17127
|
+
}
|
|
17128
|
+
const links = [];
|
|
17129
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17130
|
+
const addLink = (source, target) => {
|
|
17131
|
+
const key = `${source} ${target}`;
|
|
17132
|
+
if (!seen.has(key)) {
|
|
17133
|
+
seen.add(key);
|
|
17134
|
+
links.push({ source, target });
|
|
17135
|
+
}
|
|
17136
|
+
};
|
|
17137
|
+
for (const file of collectFiles(srcDir, (ext) => ext in EXT_TO_LANG)) {
|
|
17138
|
+
let code;
|
|
17139
|
+
try {
|
|
17140
|
+
code = readFileSync6(file, "utf-8");
|
|
17141
|
+
} catch {
|
|
17142
|
+
continue;
|
|
17143
|
+
}
|
|
17144
|
+
const lines = code.split("\n");
|
|
17145
|
+
let currentSymbol = null;
|
|
17146
|
+
let pending = [];
|
|
17147
|
+
for (const raw of lines) {
|
|
17148
|
+
const line = raw.trim();
|
|
17149
|
+
const idsHere = [...raw.matchAll(REQ_ID_RE)].map((m) => m[0]).filter((id) => reqSet.has(id));
|
|
17150
|
+
const decl = DECL_RE.exec(raw);
|
|
17151
|
+
if (decl) {
|
|
17152
|
+
const symbol = `${file}::${decl[1] ?? decl[2] ?? decl[3]}`;
|
|
17153
|
+
currentSymbol = symbol;
|
|
17154
|
+
for (const id of [...pending, ...idsHere]) {
|
|
17155
|
+
addLink(id, symbol);
|
|
17156
|
+
}
|
|
17157
|
+
pending = [];
|
|
17158
|
+
continue;
|
|
17159
|
+
}
|
|
17160
|
+
if (idsHere.length === 0) {
|
|
17161
|
+
continue;
|
|
17162
|
+
}
|
|
17163
|
+
if (line.startsWith("//") || line.startsWith("*") || line.startsWith("/*")) {
|
|
17164
|
+
pending.push(...idsHere);
|
|
17165
|
+
} else if (currentSymbol) {
|
|
17166
|
+
for (const id of idsHere) {
|
|
17167
|
+
addLink(id, currentSymbol);
|
|
17168
|
+
}
|
|
17169
|
+
} else {
|
|
17170
|
+
for (const id of idsHere) {
|
|
17171
|
+
addLink(id, file);
|
|
17172
|
+
}
|
|
17173
|
+
}
|
|
17174
|
+
}
|
|
17175
|
+
for (const id of pending) {
|
|
17176
|
+
addLink(id, file);
|
|
17177
|
+
}
|
|
17178
|
+
}
|
|
17179
|
+
return links;
|
|
17180
|
+
}
|
|
17122
17181
|
function resolveTraceInputs(flags) {
|
|
17123
17182
|
return {
|
|
17124
17183
|
specsFile: flags["specs"] ?? "storage/specs/requirements.md",
|
|
@@ -17175,14 +17234,25 @@ Requirements: ${data.requirementIds.length}, referenced in code: ${covered.lengt
|
|
|
17175
17234
|
return ExitCode.GENERAL_ERROR;
|
|
17176
17235
|
}
|
|
17177
17236
|
const { specsFile, srcDir } = resolveTraceInputs(flags);
|
|
17178
|
-
const
|
|
17237
|
+
const links = buildSymbolTraceLinks(specsFile, srcDir);
|
|
17179
17238
|
const analyzer = createImpactAnalyzer();
|
|
17180
|
-
const result = analyzer.analyze(targetId,
|
|
17239
|
+
const result = analyzer.analyze(targetId, links);
|
|
17240
|
+
const affectedReqs = result.affectedIds.filter((id) => /^REQ-[A-Z]{2,6}-\d{3}$/.test(id));
|
|
17241
|
+
const affectedSymbols = result.affectedIds.filter((id) => !/^REQ-[A-Z]{2,6}-\d{3}$/.test(id));
|
|
17181
17242
|
console.log(`Impact analysis for ${targetId}:`);
|
|
17182
17243
|
console.log(` Level: ${result.level}`);
|
|
17183
|
-
console.log(` Affected: ${result.affectedIds.length} item(s)`);
|
|
17184
|
-
|
|
17185
|
-
console.log(
|
|
17244
|
+
console.log(` Affected: ${result.affectedIds.length} item(s) (${affectedSymbols.length} symbol(s), ${affectedReqs.length} requirement(s))`);
|
|
17245
|
+
if (affectedSymbols.length > 0) {
|
|
17246
|
+
console.log(" Implementing code:");
|
|
17247
|
+
for (const s of affectedSymbols) {
|
|
17248
|
+
console.log(` - ${s}`);
|
|
17249
|
+
}
|
|
17250
|
+
}
|
|
17251
|
+
if (affectedReqs.length > 0) {
|
|
17252
|
+
console.log(" Coupled requirements (share implementing code):");
|
|
17253
|
+
for (const r of affectedReqs) {
|
|
17254
|
+
console.log(` - ${r}`);
|
|
17255
|
+
}
|
|
17186
17256
|
}
|
|
17187
17257
|
if (result.affectedIds.length === 0) {
|
|
17188
17258
|
console.log(` \u2139 No trace links for '${targetId}' in ${specsFile} / ${srcDir}.`);
|
|
@@ -18823,7 +18893,7 @@ async function handleReqValidate(filePath) {
|
|
|
18823
18893
|
for (const req of requirements) {
|
|
18824
18894
|
const analysis = validator.analyze(req.text);
|
|
18825
18895
|
const validation = validator.validate(req.text);
|
|
18826
|
-
console.log(`${req.id}: pattern=${analysis.pattern}, confidence=${analysis.confidence}`);
|
|
18896
|
+
console.log(`${req.id}: pattern=${analysis.pattern}, confidence=${analysis.confidence.toFixed(2)}`);
|
|
18827
18897
|
if (!validation.valid) {
|
|
18828
18898
|
hasIssues = true;
|
|
18829
18899
|
for (const issue of validation.issues) {
|
|
@@ -18834,7 +18904,7 @@ async function handleReqValidate(filePath) {
|
|
|
18834
18904
|
if (requirements.length === 0) {
|
|
18835
18905
|
console.log("No requirements found in file");
|
|
18836
18906
|
if (/REQ-/i.test(content)) {
|
|
18837
|
-
const headingLike = /^#{1,4}\s+REQ-[A-Z]{
|
|
18907
|
+
const headingLike = /^#{1,4}\s+REQ-[A-Z]{2,6}-\d{3}:/m.test(content);
|
|
18838
18908
|
console.error('\u26A0 Found "REQ-" text but no parseable requirements. Requirements must be Markdown headings shaped like:');
|
|
18839
18909
|
console.error(" ## REQ-XXX-000: <title> (XXX = 3-letter domain code)");
|
|
18840
18910
|
console.error(" **\u8981\u4EF6**:");
|
|
@@ -19022,7 +19092,7 @@ Interfaces: ${section.interfaces.join(", ")}`);
|
|
|
19022
19092
|
}
|
|
19023
19093
|
}
|
|
19024
19094
|
function deriveC4FromRequirements(content) {
|
|
19025
|
-
const reqRe = /^#{1,4}\s+(REQ-([A-Z]{
|
|
19095
|
+
const reqRe = /^#{1,4}\s+(REQ-([A-Z]{2,6})-\d{3}):\s*(.*)$/gm;
|
|
19026
19096
|
const reqs = [];
|
|
19027
19097
|
let m;
|
|
19028
19098
|
while ((m = reqRe.exec(content)) !== null) {
|
|
@@ -19056,7 +19126,7 @@ async function handleDesignC4(filePath, level = "context") {
|
|
|
19056
19126
|
let data;
|
|
19057
19127
|
if (content.trimStart().startsWith("{")) {
|
|
19058
19128
|
data = JSON.parse(content);
|
|
19059
|
-
} else if (/^#{1,4}\s+REQ-[A-Z]{
|
|
19129
|
+
} else if (/^#{1,4}\s+REQ-[A-Z]{2,6}-\d{3}/m.test(content)) {
|
|
19060
19130
|
data = deriveC4FromRequirements(content);
|
|
19061
19131
|
} else {
|
|
19062
19132
|
console.error("\u274C design:c4 expects a JSON C4 model {title, elements, relationships} or a Markdown requirements file (## REQ-XXX-000: \u2026).");
|
|
@@ -19117,15 +19187,27 @@ function extractCodegenTargets(content) {
|
|
|
19117
19187
|
return comps.map((c) => ({
|
|
19118
19188
|
name: toPascalCase(c.name ?? "Component"),
|
|
19119
19189
|
type: "class",
|
|
19120
|
-
methods: c.methods ?? []
|
|
19190
|
+
methods: c.methods ?? [],
|
|
19191
|
+
requirementIds: c.requirementIds ?? []
|
|
19121
19192
|
}));
|
|
19122
19193
|
}
|
|
19123
19194
|
const els = (data.elements ?? []).filter((e) => e.type === "component" || e.type === "container");
|
|
19124
19195
|
if (els.length > 0) {
|
|
19125
|
-
return els.map((e) => ({
|
|
19196
|
+
return els.map((e) => ({
|
|
19197
|
+
name: toPascalCase(e.name ?? e.id ?? "Component"),
|
|
19198
|
+
type: "class",
|
|
19199
|
+
methods: [],
|
|
19200
|
+
// A C4 component whose id is a requirement id carries its own trace.
|
|
19201
|
+
requirementIds: /^REQ-[A-Z]{2,6}-\d{3}$/.test(e.id ?? "") ? [e.id] : []
|
|
19202
|
+
}));
|
|
19126
19203
|
}
|
|
19127
19204
|
if (data.sections?.length) {
|
|
19128
|
-
return data.sections.map((s) => ({
|
|
19205
|
+
return data.sections.map((s) => ({
|
|
19206
|
+
name: toPascalCase(s.title ?? s.id ?? "Section"),
|
|
19207
|
+
type: "class",
|
|
19208
|
+
methods: [],
|
|
19209
|
+
requirementIds: s.requirementIds ?? []
|
|
19210
|
+
}));
|
|
19129
19211
|
}
|
|
19130
19212
|
} catch {
|
|
19131
19213
|
}
|
|
@@ -19137,7 +19219,8 @@ function extractCodegenTargets(content) {
|
|
|
19137
19219
|
targets.push({
|
|
19138
19220
|
name: toPascalCase(req.title || req.id),
|
|
19139
19221
|
type: "class",
|
|
19140
|
-
methods: [deriveMethodSignature(req.text, req.title)]
|
|
19222
|
+
methods: [deriveMethodSignature(req.text, req.title)],
|
|
19223
|
+
requirementIds: [req.id]
|
|
19141
19224
|
});
|
|
19142
19225
|
}
|
|
19143
19226
|
return targets;
|
|
@@ -19159,7 +19242,9 @@ async function handleCodegen(nameOrFile, type = "class", outPath) {
|
|
|
19159
19242
|
name: t.name,
|
|
19160
19243
|
methods: t.methods.length > 0 ? t.methods : void 0
|
|
19161
19244
|
});
|
|
19162
|
-
|
|
19245
|
+
const trace = t.requirementIds.length > 0 ? `// Implements: ${t.requirementIds.join(", ")}
|
|
19246
|
+
` : "";
|
|
19247
|
+
blocks.push(trace + result2.code);
|
|
19163
19248
|
}
|
|
19164
19249
|
const code = blocks.join("\n\n");
|
|
19165
19250
|
if (outPath) {
|
|
@@ -20720,6 +20805,7 @@ function createCLIDispatcher() {
|
|
|
20720
20805
|
export {
|
|
20721
20806
|
CLIDispatcher,
|
|
20722
20807
|
buildCodeTraceData,
|
|
20808
|
+
buildSymbolTraceLinks,
|
|
20723
20809
|
cgSubcommandHelp,
|
|
20724
20810
|
collectFiles,
|
|
20725
20811
|
createCLIDispatcher,
|