@mstar-harness/cli 0.5.3 → 1.0.0
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/mstar-harness.js +73 -16
- package/package.json +1 -1
package/dist/mstar-harness.js
CHANGED
|
@@ -4339,6 +4339,53 @@ function validateLocalHarnessRepo() {
|
|
|
4339
4339
|
}
|
|
4340
4340
|
return errors2;
|
|
4341
4341
|
}
|
|
4342
|
+
function ensureGitCheckout(repoUrl, checkoutPath, dryRun) {
|
|
4343
|
+
const notes = [];
|
|
4344
|
+
const parentDir = path3.dirname(checkoutPath);
|
|
4345
|
+
if (pathOrSymlinkExists(checkoutPath)) {
|
|
4346
|
+
const stat = fs2.lstatSync(checkoutPath);
|
|
4347
|
+
if (stat.isSymbolicLink()) {
|
|
4348
|
+
notes.push(dryRun ? `Would remove symlink at ${checkoutPath} and clone ${repoUrl}` : `Removed symlink at ${checkoutPath} (Cursor requires a real directory)`);
|
|
4349
|
+
if (dryRun)
|
|
4350
|
+
return notes;
|
|
4351
|
+
fs2.unlinkSync(checkoutPath);
|
|
4352
|
+
} else if (fs2.existsSync(path3.join(checkoutPath, ".git"))) {
|
|
4353
|
+
if (!dryRun) {
|
|
4354
|
+
runCommand(["git", "-C", checkoutPath, "pull", "--ff-only"], checkoutPath, dryRun);
|
|
4355
|
+
}
|
|
4356
|
+
notes.push(`Updated git checkout at ${checkoutPath}`);
|
|
4357
|
+
return notes;
|
|
4358
|
+
} else {
|
|
4359
|
+
throw new Error(`Path exists but is not a git checkout: ${checkoutPath}`);
|
|
4360
|
+
}
|
|
4361
|
+
}
|
|
4362
|
+
ensureDir(parentDir, dryRun);
|
|
4363
|
+
if (!dryRun) {
|
|
4364
|
+
runCommand(["git", "clone", repoUrl, checkoutPath], parentDir, dryRun);
|
|
4365
|
+
}
|
|
4366
|
+
notes.push(`${dryRun ? "Would clone" : "Cloned"} ${repoUrl} to ${checkoutPath}`);
|
|
4367
|
+
return notes;
|
|
4368
|
+
}
|
|
4369
|
+
function validateGitCheckout(checkoutPath, markerRelativePath) {
|
|
4370
|
+
const errors2 = [];
|
|
4371
|
+
if (!pathOrSymlinkExists(checkoutPath)) {
|
|
4372
|
+
errors2.push(`Missing checkout directory: ${checkoutPath}`);
|
|
4373
|
+
return errors2;
|
|
4374
|
+
}
|
|
4375
|
+
const stat = fs2.lstatSync(checkoutPath);
|
|
4376
|
+
if (stat.isSymbolicLink()) {
|
|
4377
|
+
errors2.push(`Path must be a real directory, not a symlink: ${checkoutPath}. Run: mstar-harness init --target cursor`);
|
|
4378
|
+
return errors2;
|
|
4379
|
+
}
|
|
4380
|
+
if (!fs2.existsSync(path3.join(checkoutPath, ".git"))) {
|
|
4381
|
+
errors2.push(`Path is not a git checkout: ${checkoutPath}`);
|
|
4382
|
+
}
|
|
4383
|
+
const marker = path3.join(checkoutPath, markerRelativePath);
|
|
4384
|
+
if (!fs2.existsSync(marker)) {
|
|
4385
|
+
errors2.push(`Missing marker file: ${marker}`);
|
|
4386
|
+
}
|
|
4387
|
+
return errors2;
|
|
4388
|
+
}
|
|
4342
4389
|
function ensureSymlink(target, linkPath, dryRun) {
|
|
4343
4390
|
if (pathOrSymlinkExists(linkPath)) {
|
|
4344
4391
|
const stat = fs2.lstatSync(linkPath);
|
|
@@ -4382,6 +4429,7 @@ function validateSymlink(target, linkPath) {
|
|
|
4382
4429
|
}
|
|
4383
4430
|
return errors2;
|
|
4384
4431
|
}
|
|
4432
|
+
var SDD_SCRATCH_GITIGNORE = [".mstar/sdd/", ".agents/sdd/"];
|
|
4385
4433
|
function appendGitignore(projectRoot, entries, dryRun) {
|
|
4386
4434
|
const gitignorePath = path3.join(projectRoot, ".gitignore");
|
|
4387
4435
|
const current = fs2.existsSync(gitignorePath) ? fs2.readFileSync(gitignorePath, "utf8") : "";
|
|
@@ -4399,6 +4447,9 @@ function appendGitignore(projectRoot, entries, dryRun) {
|
|
|
4399
4447
|
}
|
|
4400
4448
|
return missing.map((entry) => `Added ${entry} to .gitignore`);
|
|
4401
4449
|
}
|
|
4450
|
+
function appendHarnessProjectGitignore(projectRoot, dryRun) {
|
|
4451
|
+
return appendGitignore(projectRoot, SDD_SCRATCH_GITIGNORE, dryRun);
|
|
4452
|
+
}
|
|
4402
4453
|
function homeRelativeSourcePath(targetPath) {
|
|
4403
4454
|
const rel = path3.relative(os.homedir(), targetPath).split(path3.sep).join("/");
|
|
4404
4455
|
return rel.startsWith("..") ? targetPath : `./${rel}`;
|
|
@@ -4537,6 +4588,7 @@ function runInit(scope, dryRun) {
|
|
|
4537
4588
|
const projectRoot = resolveProjectRoot();
|
|
4538
4589
|
notes.push(ensureSymlink(HARNESS_REPO_PATH, path4.join(projectRoot, CODEX_PLUGIN_LINK), dryRun));
|
|
4539
4590
|
notes.push(...appendGitignore(projectRoot, [CODEX_PLUGIN_LINK, ".codex/agents/*.toml"], dryRun));
|
|
4591
|
+
notes.push(...appendHarnessProjectGitignore(projectRoot, dryRun));
|
|
4540
4592
|
}
|
|
4541
4593
|
notes.push(...ensureAgentLinks(scope, dryRun));
|
|
4542
4594
|
if (!dryRun)
|
|
@@ -4570,6 +4622,10 @@ function runDoctor(scope) {
|
|
|
4570
4622
|
errors2.push(`Missing .gitignore entry: ${CODEX_PLUGIN_LINK}`);
|
|
4571
4623
|
if (!lines.includes(".codex/agents/*.toml"))
|
|
4572
4624
|
errors2.push("Missing .gitignore entry: .codex/agents/*.toml");
|
|
4625
|
+
for (const entry of SDD_SCRATCH_GITIGNORE) {
|
|
4626
|
+
if (!lines.includes(entry))
|
|
4627
|
+
errors2.push(`Missing .gitignore entry: ${entry}`);
|
|
4628
|
+
}
|
|
4573
4629
|
}
|
|
4574
4630
|
errors2.push(...validateAgentLinks(scope));
|
|
4575
4631
|
return { location: pathToMarketplace, errors: errors2 };
|
|
@@ -4595,9 +4651,9 @@ function globalInstallPath() {
|
|
|
4595
4651
|
function projectInstallPath() {
|
|
4596
4652
|
return path5.join(resolveProjectRoot(), CURSOR_PLUGIN_LINK);
|
|
4597
4653
|
}
|
|
4598
|
-
function validatePluginAgents() {
|
|
4654
|
+
function validatePluginAgents(pluginRoot) {
|
|
4599
4655
|
const errors2 = [];
|
|
4600
|
-
const agentsDir = path5.join(
|
|
4656
|
+
const agentsDir = path5.join(pluginRoot, "agents");
|
|
4601
4657
|
if (!fs4.existsSync(agentsDir)) {
|
|
4602
4658
|
errors2.push(`Missing plugin agents directory: ${agentsDir}`);
|
|
4603
4659
|
return errors2;
|
|
@@ -4615,46 +4671,47 @@ function validatePluginAgents() {
|
|
|
4615
4671
|
}
|
|
4616
4672
|
return errors2;
|
|
4617
4673
|
}
|
|
4674
|
+
function ensureCursorPluginCheckout(location, dryRun) {
|
|
4675
|
+
return ensureGitCheckout(REPO_URL, location, dryRun);
|
|
4676
|
+
}
|
|
4618
4677
|
function globalInit(dryRun) {
|
|
4619
4678
|
const location = globalInstallPath();
|
|
4620
4679
|
const notes = ensureLocalHarnessRepo(dryRun);
|
|
4621
|
-
notes.push(
|
|
4680
|
+
notes.push(...ensureCursorPluginCheckout(location, dryRun));
|
|
4622
4681
|
return { location, notes };
|
|
4623
4682
|
}
|
|
4624
4683
|
function projectInit(dryRun) {
|
|
4625
4684
|
const projectRoot = resolveProjectRoot();
|
|
4626
4685
|
const location = projectInstallPath();
|
|
4627
4686
|
const notes = ensureLocalHarnessRepo(dryRun);
|
|
4628
|
-
notes.push(
|
|
4687
|
+
notes.push(...ensureCursorPluginCheckout(location, dryRun));
|
|
4629
4688
|
notes.push(...appendGitignore(projectRoot, [CURSOR_PLUGIN_LINK], dryRun));
|
|
4689
|
+
notes.push(...appendHarnessProjectGitignore(projectRoot, dryRun));
|
|
4630
4690
|
return { location, notes };
|
|
4631
4691
|
}
|
|
4632
4692
|
function globalDoctor() {
|
|
4633
4693
|
const location = globalInstallPath();
|
|
4634
4694
|
const errors2 = validateLocalHarnessRepo();
|
|
4635
|
-
errors2.push(...
|
|
4636
|
-
|
|
4637
|
-
if (!fs4.existsSync(marker)) {
|
|
4638
|
-
errors2.push(`Missing Cursor plugin marker file: ${marker}`);
|
|
4639
|
-
}
|
|
4640
|
-
errors2.push(...validatePluginAgents());
|
|
4695
|
+
errors2.push(...validateGitCheckout(location, CURSOR_PLUGIN_MARKER));
|
|
4696
|
+
errors2.push(...validatePluginAgents(location));
|
|
4641
4697
|
return { location, errors: errors2 };
|
|
4642
4698
|
}
|
|
4643
4699
|
function projectDoctor() {
|
|
4644
4700
|
const projectRoot = resolveProjectRoot();
|
|
4645
4701
|
const location = projectInstallPath();
|
|
4646
4702
|
const errors2 = validateLocalHarnessRepo();
|
|
4647
|
-
errors2.push(...
|
|
4648
|
-
const marker = path5.join(location, CURSOR_PLUGIN_MARKER);
|
|
4649
|
-
if (!fs4.existsSync(marker)) {
|
|
4650
|
-
errors2.push(`Missing Cursor plugin marker file: ${marker}`);
|
|
4651
|
-
}
|
|
4703
|
+
errors2.push(...validateGitCheckout(location, CURSOR_PLUGIN_MARKER));
|
|
4652
4704
|
const gitignorePath = path5.join(projectRoot, ".gitignore");
|
|
4653
4705
|
const gitignore = fs4.existsSync(gitignorePath) ? fs4.readFileSync(gitignorePath, "utf8") : "";
|
|
4654
4706
|
if (!gitignore.split(/\r?\n/).includes(CURSOR_PLUGIN_LINK)) {
|
|
4655
4707
|
errors2.push(`Missing .gitignore entry: ${CURSOR_PLUGIN_LINK}`);
|
|
4656
4708
|
}
|
|
4657
|
-
|
|
4709
|
+
for (const entry of SDD_SCRATCH_GITIGNORE) {
|
|
4710
|
+
if (!gitignore.split(/\r?\n/).includes(entry)) {
|
|
4711
|
+
errors2.push(`Missing .gitignore entry: ${entry}`);
|
|
4712
|
+
}
|
|
4713
|
+
}
|
|
4714
|
+
errors2.push(...validatePluginAgents(location));
|
|
4658
4715
|
return { location, errors: errors2 };
|
|
4659
4716
|
}
|
|
4660
4717
|
var cursorAdapter = {
|