dlw-machine-setup 0.4.4 → 0.4.6
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 +59 -19
- package/package.json +1 -1
package/bin/installer.js
CHANGED
|
@@ -3845,7 +3845,27 @@ function buildMCPSection(mcpConfig) {
|
|
|
3845
3845
|
}
|
|
3846
3846
|
return lines2.join("\n");
|
|
3847
3847
|
}
|
|
3848
|
-
function
|
|
3848
|
+
function resolveDomainFolder(domain) {
|
|
3849
|
+
if ((0, import_fs4.existsSync)(CONTEXTS_DIR)) {
|
|
3850
|
+
try {
|
|
3851
|
+
const entries = (0, import_fs4.readdirSync)(CONTEXTS_DIR);
|
|
3852
|
+
const match = entries.find((e) => e.toLowerCase() === domain.toLowerCase());
|
|
3853
|
+
if (match) {
|
|
3854
|
+
return { folderName: match, folderPath: (0, import_path4.join)(CONTEXTS_DIR, match) };
|
|
3855
|
+
}
|
|
3856
|
+
} catch {
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
const fallback = domain.toUpperCase();
|
|
3860
|
+
return { folderName: fallback, folderPath: (0, import_path4.join)(CONTEXTS_DIR, fallback) };
|
|
3861
|
+
}
|
|
3862
|
+
function formatPathRef(contextPath, description, agent) {
|
|
3863
|
+
if (agent === "github-copilot") {
|
|
3864
|
+
return `- [${contextPath}](../../${contextPath}) \u2014 ${description}`;
|
|
3865
|
+
}
|
|
3866
|
+
return `- \`${contextPath}\` \u2014 ${description}`;
|
|
3867
|
+
}
|
|
3868
|
+
function buildContextRefsSection(domains, agent) {
|
|
3849
3869
|
const lines2 = [
|
|
3850
3870
|
`## Context References`,
|
|
3851
3871
|
``,
|
|
@@ -3854,26 +3874,25 @@ function buildContextRefsSection(domains) {
|
|
|
3854
3874
|
];
|
|
3855
3875
|
let hasAnyFiles = false;
|
|
3856
3876
|
for (const domain of domains) {
|
|
3857
|
-
const
|
|
3858
|
-
const domainPath = (0, import_path4.join)(CONTEXTS_DIR, domainUpper);
|
|
3877
|
+
const { folderName, folderPath: domainPath } = resolveDomainFolder(domain);
|
|
3859
3878
|
if (!(0, import_fs4.existsSync)(domainPath)) continue;
|
|
3860
3879
|
const domainFiles = [];
|
|
3861
3880
|
const ctxInstructions = (0, import_path4.join)(domainPath, "context-instructions.md");
|
|
3862
3881
|
if ((0, import_fs4.existsSync)(ctxInstructions)) {
|
|
3863
3882
|
const desc = extractFirstHeading(ctxInstructions);
|
|
3864
|
-
domainFiles.push(
|
|
3883
|
+
domainFiles.push(formatPathRef(`_ai-context/${folderName}/context-instructions.md`, desc, agent));
|
|
3865
3884
|
}
|
|
3866
3885
|
const instructionsMd = (0, import_path4.join)(domainPath, "core", "instructions.md");
|
|
3867
3886
|
if ((0, import_fs4.existsSync)(instructionsMd)) {
|
|
3868
3887
|
const desc = extractFirstHeading(instructionsMd);
|
|
3869
|
-
domainFiles.push(
|
|
3888
|
+
domainFiles.push(formatPathRef(`_ai-context/${folderName}/core/instructions.md`, `${desc} (start here)`, agent));
|
|
3870
3889
|
}
|
|
3871
3890
|
const coreDir = (0, import_path4.join)(domainPath, "core");
|
|
3872
3891
|
if ((0, import_fs4.existsSync)(coreDir)) {
|
|
3873
3892
|
const coreFiles = collectMdFiles(coreDir).filter((f) => f !== "instructions.md" && !f.startsWith("instructions/"));
|
|
3874
3893
|
for (const file of coreFiles) {
|
|
3875
3894
|
const desc = extractFirstHeading((0, import_path4.join)(coreDir, file));
|
|
3876
|
-
domainFiles.push(
|
|
3895
|
+
domainFiles.push(formatPathRef(`_ai-context/${folderName}/core/${file}`, desc, agent));
|
|
3877
3896
|
}
|
|
3878
3897
|
}
|
|
3879
3898
|
const refDir = (0, import_path4.join)(domainPath, "reference");
|
|
@@ -3884,13 +3903,13 @@ function buildContextRefsSection(domains) {
|
|
|
3884
3903
|
domainFiles.push(`**Reference & cheat sheets:**`);
|
|
3885
3904
|
for (const file of refFiles) {
|
|
3886
3905
|
const desc = extractFirstHeading((0, import_path4.join)(refDir, file));
|
|
3887
|
-
domainFiles.push(
|
|
3906
|
+
domainFiles.push(formatPathRef(`_ai-context/${folderName}/reference/${file}`, desc, agent));
|
|
3888
3907
|
}
|
|
3889
3908
|
}
|
|
3890
3909
|
}
|
|
3891
3910
|
if (domainFiles.length === 0) continue;
|
|
3892
3911
|
hasAnyFiles = true;
|
|
3893
|
-
lines2.push(`### ${
|
|
3912
|
+
lines2.push(`### ${folderName}`);
|
|
3894
3913
|
lines2.push(...domainFiles);
|
|
3895
3914
|
lines2.push(``);
|
|
3896
3915
|
}
|
|
@@ -3900,14 +3919,14 @@ function buildContextRefsSection(domains) {
|
|
|
3900
3919
|
}
|
|
3901
3920
|
return lines2.join("\n");
|
|
3902
3921
|
}
|
|
3903
|
-
function buildCombinedInstructions(domains, mcpConfig) {
|
|
3922
|
+
function buildCombinedInstructions(domains, mcpConfig, agent = "") {
|
|
3904
3923
|
const lines2 = [
|
|
3905
3924
|
`# AI Development Instructions`,
|
|
3906
3925
|
``,
|
|
3907
3926
|
`> Generated by One-Shot Installer`,
|
|
3908
3927
|
``
|
|
3909
3928
|
];
|
|
3910
|
-
lines2.push(buildContextRefsSection(domains));
|
|
3929
|
+
lines2.push(buildContextRefsSection(domains, agent));
|
|
3911
3930
|
if (mcpConfig && Object.keys(mcpConfig).length > 0) {
|
|
3912
3931
|
lines2.push(buildMCPSection(mcpConfig));
|
|
3913
3932
|
}
|
|
@@ -3917,7 +3936,7 @@ async function setupInstructions(config) {
|
|
|
3917
3936
|
const { domains, agent, mcpConfig } = config;
|
|
3918
3937
|
switch (agent) {
|
|
3919
3938
|
case "claude-code": {
|
|
3920
|
-
const content = buildCombinedInstructions(domains, mcpConfig);
|
|
3939
|
+
const content = buildCombinedInstructions(domains, mcpConfig, agent);
|
|
3921
3940
|
upsertBlock((0, import_path4.join)(process.cwd(), "CLAUDE.md"), content);
|
|
3922
3941
|
break;
|
|
3923
3942
|
}
|
|
@@ -3932,14 +3951,14 @@ applyTo: "**"
|
|
|
3932
3951
|
|
|
3933
3952
|
`, "utf-8");
|
|
3934
3953
|
}
|
|
3935
|
-
const body = buildCombinedInstructions(domains, mcpConfig);
|
|
3954
|
+
const body = buildCombinedInstructions(domains, mcpConfig, agent);
|
|
3936
3955
|
upsertBlock(filePath, body);
|
|
3937
3956
|
break;
|
|
3938
3957
|
}
|
|
3939
3958
|
case "cursor": {
|
|
3940
3959
|
const cursorDir = (0, import_path4.join)(process.cwd(), ".cursor", "rules");
|
|
3941
3960
|
if (!(0, import_fs4.existsSync)(cursorDir)) (0, import_fs4.mkdirSync)(cursorDir, { recursive: true });
|
|
3942
|
-
const body = buildCombinedInstructions(domains, mcpConfig);
|
|
3961
|
+
const body = buildCombinedInstructions(domains, mcpConfig, agent);
|
|
3943
3962
|
upsertBlock((0, import_path4.join)(cursorDir, `instructions.mdc`), body);
|
|
3944
3963
|
break;
|
|
3945
3964
|
}
|
|
@@ -4143,12 +4162,28 @@ async function execute(config, token, repo) {
|
|
|
4143
4162
|
result.success = false;
|
|
4144
4163
|
return result;
|
|
4145
4164
|
}
|
|
4165
|
+
const statePath = (0, import_path5.join)(config.projectPath, ".one-shot-state.json");
|
|
4166
|
+
let previousState = {};
|
|
4167
|
+
try {
|
|
4168
|
+
if ((0, import_fs5.existsSync)(statePath)) {
|
|
4169
|
+
previousState = JSON.parse((0, import_fs5.readFileSync)(statePath, "utf-8"));
|
|
4170
|
+
}
|
|
4171
|
+
} catch {
|
|
4172
|
+
}
|
|
4173
|
+
const allDomains = [.../* @__PURE__ */ new Set([
|
|
4174
|
+
...previousState.domains ?? [],
|
|
4175
|
+
...result.domainsInstalled
|
|
4176
|
+
])];
|
|
4177
|
+
const mergedMcpConfig = {
|
|
4178
|
+
...previousState.mcpConfigs ?? {},
|
|
4179
|
+
...config.mcpConfig
|
|
4180
|
+
};
|
|
4146
4181
|
process.stdout.write(` Writing ${instructionFilePath}... `);
|
|
4147
4182
|
try {
|
|
4148
4183
|
await setupInstructions({
|
|
4149
|
-
domains:
|
|
4184
|
+
domains: allDomains,
|
|
4150
4185
|
agent: config.agent,
|
|
4151
|
-
mcpConfig:
|
|
4186
|
+
mcpConfig: mergedMcpConfig
|
|
4152
4187
|
});
|
|
4153
4188
|
result.instructionsCreated = true;
|
|
4154
4189
|
console.log("\u2713");
|
|
@@ -4173,12 +4208,17 @@ async function execute(config, token, repo) {
|
|
|
4173
4208
|
console.log(` Path: ${mcpConfigPath}`);
|
|
4174
4209
|
}
|
|
4175
4210
|
result.success = result.domainsFailed.length === 0 && result.instructionsCreated && result.mcpConfigured;
|
|
4211
|
+
const allPersonas = [.../* @__PURE__ */ new Set([
|
|
4212
|
+
...previousState.personas ?? [],
|
|
4213
|
+
...config.personas.map((p) => p.id)
|
|
4214
|
+
])];
|
|
4176
4215
|
const state = {
|
|
4177
4216
|
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4178
4217
|
agent: config.agent,
|
|
4179
|
-
personas:
|
|
4180
|
-
domains:
|
|
4181
|
-
mcpServers: Object.keys(
|
|
4218
|
+
personas: allPersonas,
|
|
4219
|
+
domains: allDomains,
|
|
4220
|
+
mcpServers: Object.keys(mergedMcpConfig),
|
|
4221
|
+
mcpConfigs: mergedMcpConfig,
|
|
4182
4222
|
files: {
|
|
4183
4223
|
instructions: instructionFilePath,
|
|
4184
4224
|
mcpConfig: mcpConfigPath,
|
|
@@ -4186,7 +4226,7 @@ async function execute(config, token, repo) {
|
|
|
4186
4226
|
}
|
|
4187
4227
|
};
|
|
4188
4228
|
try {
|
|
4189
|
-
(0, import_fs5.writeFileSync)(
|
|
4229
|
+
(0, import_fs5.writeFileSync)(statePath, JSON.stringify(state, null, 2), "utf-8");
|
|
4190
4230
|
} catch {
|
|
4191
4231
|
}
|
|
4192
4232
|
return result;
|