@locusai/cli 0.9.10 → 0.9.11

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.
@@ -30921,12 +30921,34 @@ class WorktreeManager {
30921
30921
  const status = this.git("status --porcelain", worktreePath).trim();
30922
30922
  return status.length > 0;
30923
30923
  }
30924
- commitChanges(worktreePath, message) {
30925
- if (!this.hasChanges(worktreePath)) {
30924
+ hasCommitsAhead(worktreePath, baseBranch) {
30925
+ try {
30926
+ const count = this.git(`rev-list --count "${baseBranch}..HEAD"`, worktreePath).trim();
30927
+ return Number.parseInt(count, 10) > 0;
30928
+ } catch {
30929
+ return false;
30930
+ }
30931
+ }
30932
+ commitChanges(worktreePath, message, baseBranch) {
30933
+ const hasUncommittedChanges = this.hasChanges(worktreePath);
30934
+ if (!hasUncommittedChanges) {
30935
+ if (baseBranch && this.hasCommitsAhead(worktreePath, baseBranch)) {
30936
+ const hash3 = this.git("rev-parse HEAD", worktreePath).trim();
30937
+ this.log(`Agent already committed changes (${hash3.slice(0, 8)}); skipping additional commit`, "info");
30938
+ return hash3;
30939
+ }
30926
30940
  this.log("No changes to commit", "info");
30927
30941
  return null;
30928
30942
  }
30929
30943
  this.git("add -A", worktreePath);
30944
+ try {
30945
+ this.git("reset HEAD -- .locus/project/progress.md", worktreePath);
30946
+ } catch {}
30947
+ const staged = this.git("diff --cached --name-only", worktreePath).trim();
30948
+ if (!staged) {
30949
+ this.log("No changes to commit (only progress.md was modified)", "info");
30950
+ return null;
30951
+ }
30930
30952
  this.gitExec(["commit", "-m", message], worktreePath);
30931
30953
  const hash2 = this.git("rev-parse HEAD", worktreePath).trim();
30932
30954
  this.log(`Committed: ${hash2.slice(0, 8)}`, "success");
@@ -31175,7 +31197,9 @@ ${comment.text}
31175
31197
  prompt += `## Instructions
31176
31198
  1. Complete this task.
31177
31199
  2. **Artifact Management**: If you create any high-level documentation (PRDs, technical drafts, architecture docs), you MUST save them in \`.locus/artifacts/\`. Do NOT create them in the root directory.
31178
- 3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).`;
31200
+ 3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
31201
+ 4. **Git**: Do NOT run \`git add\`, \`git commit\`, \`git push\`, or create branches. The Locus system handles all git operations automatically after your execution completes.
31202
+ 5. **Progress**: Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically.`;
31179
31203
  return prompt;
31180
31204
  }
31181
31205
  async buildGenericPrompt(query) {
@@ -31242,7 +31266,9 @@ There is an index file in the .locus/codebase-index.json and if you need you can
31242
31266
  }
31243
31267
  prompt += `## Instructions
31244
31268
  1. Execute the prompt based on the provided project context.
31245
- 2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).`;
31269
+ 2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
31270
+ 3. **Git**: Do NOT run \`git add\`, \`git commit\`, \`git push\`, or create branches. The Locus system handles all git operations automatically after your execution completes.
31271
+ 4. **Progress**: Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically.`;
31246
31272
  return prompt;
31247
31273
  }
31248
31274
  getProjectConfig() {
@@ -31505,7 +31531,7 @@ class AgentWorker {
31505
31531
  executor: taskExecutor
31506
31532
  };
31507
31533
  }
31508
- commitAndPushWorktree(worktreePath, task2) {
31534
+ commitAndPushWorktree(worktreePath, task2, baseBranch) {
31509
31535
  if (!this.worktreeManager) {
31510
31536
  return { branch: null, pushed: false, pushFailed: false };
31511
31537
  }
@@ -31522,7 +31548,7 @@ class AgentWorker {
31522
31548
 
31523
31549
  ${trailers.join(`
31524
31550
  `)}`;
31525
- const hash2 = this.worktreeManager.commitChanges(worktreePath, commitMessage);
31551
+ const hash2 = this.worktreeManager.commitChanges(worktreePath, commitMessage, baseBranch);
31526
31552
  if (!hash2) {
31527
31553
  this.log("No changes to commit for this task", "info");
31528
31554
  return {
@@ -31612,7 +31638,7 @@ ${trailers.join(`
31612
31638
  let prError = null;
31613
31639
  let noChanges = false;
31614
31640
  if (result.success && worktreePath) {
31615
- const commitResult = this.commitAndPushWorktree(worktreePath, fullTask);
31641
+ const commitResult = this.commitAndPushWorktree(worktreePath, fullTask, baseBranch ?? undefined);
31616
31642
  taskBranch = commitResult.branch;
31617
31643
  branchPushed = commitResult.pushed;
31618
31644
  keepBranch = taskBranch !== null;
package/bin/locus.js CHANGED
@@ -38251,7 +38251,9 @@ ${comment.text}
38251
38251
  prompt += `## Instructions
38252
38252
  1. Complete this task.
38253
38253
  2. **Artifact Management**: If you create any high-level documentation (PRDs, technical drafts, architecture docs), you MUST save them in \`.locus/artifacts/\`. Do NOT create them in the root directory.
38254
- 3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).`;
38254
+ 3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
38255
+ 4. **Git**: Do NOT run \`git add\`, \`git commit\`, \`git push\`, or create branches. The Locus system handles all git operations automatically after your execution completes.
38256
+ 5. **Progress**: Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically.`;
38255
38257
  return prompt;
38256
38258
  }
38257
38259
  async buildGenericPrompt(query) {
@@ -38318,7 +38320,9 @@ There is an index file in the .locus/codebase-index.json and if you need you can
38318
38320
  }
38319
38321
  prompt += `## Instructions
38320
38322
  1. Execute the prompt based on the provided project context.
38321
- 2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).`;
38323
+ 2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
38324
+ 3. **Git**: Do NOT run \`git add\`, \`git commit\`, \`git push\`, or create branches. The Locus system handles all git operations automatically after your execution completes.
38325
+ 4. **Progress**: Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically.`;
38322
38326
  return prompt;
38323
38327
  }
38324
38328
  getProjectConfig() {
@@ -38607,12 +38611,34 @@ class WorktreeManager {
38607
38611
  const status = this.git("status --porcelain", worktreePath).trim();
38608
38612
  return status.length > 0;
38609
38613
  }
38610
- commitChanges(worktreePath, message) {
38611
- if (!this.hasChanges(worktreePath)) {
38614
+ hasCommitsAhead(worktreePath, baseBranch) {
38615
+ try {
38616
+ const count = this.git(`rev-list --count "${baseBranch}..HEAD"`, worktreePath).trim();
38617
+ return Number.parseInt(count, 10) > 0;
38618
+ } catch {
38619
+ return false;
38620
+ }
38621
+ }
38622
+ commitChanges(worktreePath, message, baseBranch) {
38623
+ const hasUncommittedChanges = this.hasChanges(worktreePath);
38624
+ if (!hasUncommittedChanges) {
38625
+ if (baseBranch && this.hasCommitsAhead(worktreePath, baseBranch)) {
38626
+ const hash3 = this.git("rev-parse HEAD", worktreePath).trim();
38627
+ this.log(`Agent already committed changes (${hash3.slice(0, 8)}); skipping additional commit`, "info");
38628
+ return hash3;
38629
+ }
38612
38630
  this.log("No changes to commit", "info");
38613
38631
  return null;
38614
38632
  }
38615
38633
  this.git("add -A", worktreePath);
38634
+ try {
38635
+ this.git("reset HEAD -- .locus/project/progress.md", worktreePath);
38636
+ } catch {}
38637
+ const staged = this.git("diff --cached --name-only", worktreePath).trim();
38638
+ if (!staged) {
38639
+ this.log("No changes to commit (only progress.md was modified)", "info");
38640
+ return null;
38641
+ }
38616
38642
  this.gitExec(["commit", "-m", message], worktreePath);
38617
38643
  const hash2 = this.git("rev-parse HEAD", worktreePath).trim();
38618
38644
  this.log(`Committed: ${hash2.slice(0, 8)}`, "success");
@@ -38875,7 +38901,7 @@ class AgentWorker {
38875
38901
  executor: taskExecutor
38876
38902
  };
38877
38903
  }
38878
- commitAndPushWorktree(worktreePath, task2) {
38904
+ commitAndPushWorktree(worktreePath, task2, baseBranch) {
38879
38905
  if (!this.worktreeManager) {
38880
38906
  return { branch: null, pushed: false, pushFailed: false };
38881
38907
  }
@@ -38892,7 +38918,7 @@ class AgentWorker {
38892
38918
 
38893
38919
  ${trailers.join(`
38894
38920
  `)}`;
38895
- const hash2 = this.worktreeManager.commitChanges(worktreePath, commitMessage);
38921
+ const hash2 = this.worktreeManager.commitChanges(worktreePath, commitMessage, baseBranch);
38896
38922
  if (!hash2) {
38897
38923
  this.log("No changes to commit for this task", "info");
38898
38924
  return {
@@ -38982,7 +39008,7 @@ ${trailers.join(`
38982
39008
  let prError = null;
38983
39009
  let noChanges = false;
38984
39010
  if (result.success && worktreePath) {
38985
- const commitResult = this.commitAndPushWorktree(worktreePath, fullTask);
39011
+ const commitResult = this.commitAndPushWorktree(worktreePath, fullTask, baseBranch ?? undefined);
38986
39012
  taskBranch = commitResult.branch;
38987
39013
  branchPushed = commitResult.pushed;
38988
39014
  keepBranch = taskBranch !== null;
@@ -42665,6 +42691,13 @@ Complex tasks must be planned before writing code. Create \`.locus/plans/<task-n
42665
42691
  - No new dependencies without explicit approval.
42666
42692
  - Never put raw secrets or credentials in the codebase.
42667
42693
 
42694
+ ## Git
42695
+
42696
+ - Do NOT run \`git add\`, \`git commit\`, \`git push\`, or create branches.
42697
+ - The Locus system handles all git operations (commit, push, PR creation) automatically after your execution completes.
42698
+ - Focus only on making file changes — the orchestrator takes care of version control.
42699
+ - Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically. Changes to this file are excluded from commits to prevent merge conflicts across concurrent agents.
42700
+
42668
42701
  ## Avoiding Hallucinated / Slop Code
42669
42702
 
42670
42703
  - Ask before assuming. If requirements are ambiguous, incomplete, or could be interpreted multiple ways, stop and ask clarifying questions rather than guessing.
@@ -42808,8 +42841,9 @@ class ConfigManager {
42808
42841
  writeFileSync7(settingsPath, JSON.stringify(ordered, null, 2), "utf-8");
42809
42842
  }
42810
42843
  }
42811
- if (!existsSync15(locusMdPath)) {
42812
- writeFileSync7(locusMdPath, LOCUS_MD_TEMPLATE);
42844
+ const locusMdExisted = existsSync15(locusMdPath);
42845
+ writeFileSync7(locusMdPath, LOCUS_MD_TEMPLATE);
42846
+ if (!locusMdExisted) {
42813
42847
  result.directoriesCreated.push(".locus/LOCUS.md");
42814
42848
  }
42815
42849
  const locusSubdirs = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusai/cli",
3
- "version": "0.9.10",
3
+ "version": "0.9.11",
4
4
  "description": "CLI for Locus - AI-native project management platform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "author": "",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@locusai/sdk": "^0.9.10"
35
+ "@locusai/sdk": "^0.9.11"
36
36
  },
37
37
  "devDependencies": {}
38
38
  }