dlw-machine-setup 0.4.2 → 0.4.3
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/bin/installer.js +6 -47
- package/package.json +1 -1
package/bin/installer.js
CHANGED
|
@@ -3783,7 +3783,6 @@ var import_path4 = require("path");
|
|
|
3783
3783
|
var CONTEXTS_DIR = (0, import_path4.join)(process.cwd(), "_ai-context");
|
|
3784
3784
|
var MARKER_START = "<!-- one-shot-installer:start -->";
|
|
3785
3785
|
var MARKER_END = "<!-- one-shot-installer:end -->";
|
|
3786
|
-
var SNIPPET_FILENAME = "context-instructions.md";
|
|
3787
3786
|
function upsertBlock(filePath, block) {
|
|
3788
3787
|
const marked = `${MARKER_START}
|
|
3789
3788
|
${block}
|
|
@@ -3803,20 +3802,12 @@ ${MARKER_END}`;
|
|
|
3803
3802
|
(0, import_fs4.writeFileSync)(filePath, existing + separator + marked, "utf-8");
|
|
3804
3803
|
}
|
|
3805
3804
|
}
|
|
3806
|
-
function downgradeHeadings(content) {
|
|
3807
|
-
let inCodeBlock = false;
|
|
3808
|
-
return content.split("\n").map((line) => {
|
|
3809
|
-
if (/^ {0,3}```/.test(line)) inCodeBlock = !inCodeBlock;
|
|
3810
|
-
if (inCodeBlock) return line;
|
|
3811
|
-
return line.replace(/^(#{1,5}) /, "$1# ");
|
|
3812
|
-
}).join("\n");
|
|
3813
|
-
}
|
|
3814
3805
|
function collectMdFiles(dir) {
|
|
3815
3806
|
if (!(0, import_fs4.existsSync)(dir)) return [];
|
|
3816
3807
|
const entries = (0, import_fs4.readdirSync)(dir, { recursive: true });
|
|
3817
3808
|
return entries.filter((entry) => {
|
|
3818
3809
|
const fullPath = (0, import_path4.join)(dir, entry);
|
|
3819
|
-
return entry.endsWith(".md") && (0, import_fs4.statSync)(fullPath).isFile()
|
|
3810
|
+
return entry.endsWith(".md") && (0, import_fs4.statSync)(fullPath).isFile();
|
|
3820
3811
|
}).map((entry) => entry.replace(/\\/g, "/")).sort();
|
|
3821
3812
|
}
|
|
3822
3813
|
function extractFirstHeading(filePath) {
|
|
@@ -3832,34 +3823,6 @@ function extractFirstHeading(filePath) {
|
|
|
3832
3823
|
const basename = filePath.split(/[/\\]/).pop() ?? "";
|
|
3833
3824
|
return basename.replace(/\.md$/i, "").replace(/[-_]+/g, " ");
|
|
3834
3825
|
}
|
|
3835
|
-
function buildWorkflowSection(domains) {
|
|
3836
|
-
const sections = [];
|
|
3837
|
-
const generalSnippet = (0, import_path4.join)(CONTEXTS_DIR, "GENERAL", SNIPPET_FILENAME);
|
|
3838
|
-
if ((0, import_fs4.existsSync)(generalSnippet)) {
|
|
3839
|
-
const raw = (0, import_fs4.readFileSync)(generalSnippet, "utf-8").trim();
|
|
3840
|
-
if (raw) sections.push(downgradeHeadings(raw));
|
|
3841
|
-
}
|
|
3842
|
-
for (const domain of domains) {
|
|
3843
|
-
const domainUpper = domain.toUpperCase();
|
|
3844
|
-
if (domainUpper === "GENERAL") continue;
|
|
3845
|
-
const snippetPath = (0, import_path4.join)(CONTEXTS_DIR, domainUpper, SNIPPET_FILENAME);
|
|
3846
|
-
if (!(0, import_fs4.existsSync)(snippetPath)) continue;
|
|
3847
|
-
const raw = (0, import_fs4.readFileSync)(snippetPath, "utf-8").trim();
|
|
3848
|
-
if (!raw) continue;
|
|
3849
|
-
sections.push(downgradeHeadings(raw));
|
|
3850
|
-
}
|
|
3851
|
-
return sections.length > 0 ? sections.join("\n\n") + "\n" : "";
|
|
3852
|
-
}
|
|
3853
|
-
function cleanupWorkflowSnippets(domains) {
|
|
3854
|
-
for (const domain of domains) {
|
|
3855
|
-
const domainUpper = domain.toUpperCase();
|
|
3856
|
-
const snippetPath = (0, import_path4.join)(CONTEXTS_DIR, domainUpper, SNIPPET_FILENAME);
|
|
3857
|
-
try {
|
|
3858
|
-
(0, import_fs4.unlinkSync)(snippetPath);
|
|
3859
|
-
} catch {
|
|
3860
|
-
}
|
|
3861
|
-
}
|
|
3862
|
-
}
|
|
3863
3826
|
function buildMCPSection(mcpConfig) {
|
|
3864
3827
|
const entries = Object.entries(mcpConfig);
|
|
3865
3828
|
if (entries.length === 0) return "";
|
|
@@ -3895,6 +3858,11 @@ function buildContextRefsSection(domains) {
|
|
|
3895
3858
|
const domainPath = (0, import_path4.join)(CONTEXTS_DIR, domainUpper);
|
|
3896
3859
|
if (!(0, import_fs4.existsSync)(domainPath)) continue;
|
|
3897
3860
|
const domainFiles = [];
|
|
3861
|
+
const ctxInstructions = (0, import_path4.join)(domainPath, "context-instructions.md");
|
|
3862
|
+
if ((0, import_fs4.existsSync)(ctxInstructions)) {
|
|
3863
|
+
const desc = extractFirstHeading(ctxInstructions);
|
|
3864
|
+
domainFiles.push(`- \`_ai-context/${domainUpper}/context-instructions.md\` \u2014 ${desc}`);
|
|
3865
|
+
}
|
|
3898
3866
|
const instructionsMd = (0, import_path4.join)(domainPath, "core", "instructions.md");
|
|
3899
3867
|
if ((0, import_fs4.existsSync)(instructionsMd)) {
|
|
3900
3868
|
const desc = extractFirstHeading(instructionsMd);
|
|
@@ -3943,12 +3911,6 @@ function buildCombinedInstructions(domains, mcpConfig) {
|
|
|
3943
3911
|
if (mcpConfig && Object.keys(mcpConfig).length > 0) {
|
|
3944
3912
|
lines2.push(buildMCPSection(mcpConfig));
|
|
3945
3913
|
}
|
|
3946
|
-
const workflowContent = buildWorkflowSection(domains);
|
|
3947
|
-
if (workflowContent) {
|
|
3948
|
-
lines2.push(`## Domain-Specific Development Workflows
|
|
3949
|
-
`);
|
|
3950
|
-
lines2.push(workflowContent);
|
|
3951
|
-
}
|
|
3952
3914
|
return lines2.join("\n");
|
|
3953
3915
|
}
|
|
3954
3916
|
async function setupInstructions(config) {
|
|
@@ -3957,7 +3919,6 @@ async function setupInstructions(config) {
|
|
|
3957
3919
|
case "claude-code": {
|
|
3958
3920
|
const content = buildCombinedInstructions(domains, mcpConfig);
|
|
3959
3921
|
upsertBlock((0, import_path4.join)(process.cwd(), "CLAUDE.md"), content);
|
|
3960
|
-
cleanupWorkflowSnippets(domains);
|
|
3961
3922
|
break;
|
|
3962
3923
|
}
|
|
3963
3924
|
case "github-copilot": {
|
|
@@ -3973,7 +3934,6 @@ applyTo: "**"
|
|
|
3973
3934
|
}
|
|
3974
3935
|
const body = buildCombinedInstructions(domains, mcpConfig);
|
|
3975
3936
|
upsertBlock(filePath, body);
|
|
3976
|
-
cleanupWorkflowSnippets(domains);
|
|
3977
3937
|
break;
|
|
3978
3938
|
}
|
|
3979
3939
|
case "cursor": {
|
|
@@ -3981,7 +3941,6 @@ applyTo: "**"
|
|
|
3981
3941
|
if (!(0, import_fs4.existsSync)(cursorDir)) (0, import_fs4.mkdirSync)(cursorDir, { recursive: true });
|
|
3982
3942
|
const body = buildCombinedInstructions(domains, mcpConfig);
|
|
3983
3943
|
upsertBlock((0, import_path4.join)(cursorDir, `instructions.mdc`), body);
|
|
3984
|
-
cleanupWorkflowSnippets(domains);
|
|
3985
3944
|
break;
|
|
3986
3945
|
}
|
|
3987
3946
|
default:
|