@lsctech/polaris 0.3.12 → 0.3.13
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/cli/adopt-canon.js +18 -6
- package/package.json +1 -1
package/dist/cli/adopt-canon.js
CHANGED
|
@@ -132,18 +132,30 @@ If no doctrine docs are relevant, return an empty array for relevant_docs.`;
|
|
|
132
132
|
cwd: repoRoot,
|
|
133
133
|
});
|
|
134
134
|
const stdout = (result.stdout ?? "").trim();
|
|
135
|
+
// Try single-line JSON first (ideal case)
|
|
135
136
|
const jsonLine = stdout
|
|
136
137
|
.split("\n")
|
|
137
138
|
.reverse()
|
|
138
139
|
.find((l) => l.trim().startsWith("{") && l.includes("relevant_docs"));
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
if (jsonLine) {
|
|
141
|
+
try {
|
|
142
|
+
return JSON.parse(jsonLine);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// fall through to block extraction
|
|
146
|
+
}
|
|
143
147
|
}
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
// Try extracting JSON block (handles multi-line or code-fenced output)
|
|
149
|
+
const blockMatch = stdout.match(/\{[\s\S]*"relevant_docs"[\s\S]*\}/);
|
|
150
|
+
if (blockMatch) {
|
|
151
|
+
try {
|
|
152
|
+
return JSON.parse(blockMatch[0]);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
146
157
|
}
|
|
158
|
+
return null;
|
|
147
159
|
}
|
|
148
160
|
async function enrichCanonFiles(repoRoot) {
|
|
149
161
|
let config = null;
|