@locusai/sdk 0.9.10 → 0.9.12
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/agent/worker.d.ts.map +1 -1
- package/dist/agent/worker.js +35 -9
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/prompt-builder.d.ts.map +1 -1
- package/dist/git/git-utils.d.ts.map +1 -1
- package/dist/index-node.js +35 -9
- package/dist/worktree/worktree-manager.d.ts +12 -1
- package/dist/worktree/worktree-manager.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/agent/worker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,iBAAiB,CAAC;AA4B5D,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,yFAAyF;IACzF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sDAAsD;IACtD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAWD;;;GAGG;AACH,qBAAa,WAAW;IAoBV,OAAO,CAAC,MAAM;IAnB1B,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAW;IAG3B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,SAAS,CAA0B;IAG3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a,CAAgB;IACrC,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,SAAS,CAA0B;IAG3C,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,iBAAiB,CAA+C;IACxE,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,kBAAkB,CAAS;IACnC,0DAA0D;IAC1D,OAAO,CAAC,UAAU,CAAuB;gBAErB,MAAM,EAAE,YAAY;IAqFxC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAgB;YAe5D,eAAe;YAcf,WAAW;IA+CzB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAqD1B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAyE7B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAgCzB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;YAsBb,WAAW;IAoGzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAkBtB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,aAAa;YAgBP,iBAAiB;IAYzB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAwI3B"}
|
package/dist/agent/worker.js
CHANGED
|
@@ -532,7 +532,10 @@ var LOCUS_GITIGNORE_PATTERNS = [
|
|
|
532
532
|
".locus/settings.json",
|
|
533
533
|
"",
|
|
534
534
|
"# Locus AI - Configuration (contains project context, progress, etc.)",
|
|
535
|
-
".locus/config.json"
|
|
535
|
+
".locus/config.json",
|
|
536
|
+
"",
|
|
537
|
+
"# Locus AI - Project progress (contains project progress, etc.)",
|
|
538
|
+
".locus/project/progress.md"
|
|
536
539
|
];
|
|
537
540
|
function getLocusPath(projectPath, fileName) {
|
|
538
541
|
if (fileName === "projectContextFile" || fileName === "projectProgressFile") {
|
|
@@ -1938,12 +1941,31 @@ class WorktreeManager {
|
|
|
1938
1941
|
const status = this.git("status --porcelain", worktreePath).trim();
|
|
1939
1942
|
return status.length > 0;
|
|
1940
1943
|
}
|
|
1941
|
-
|
|
1942
|
-
|
|
1944
|
+
hasCommitsAhead(worktreePath, baseBranch) {
|
|
1945
|
+
try {
|
|
1946
|
+
const count = this.git(`rev-list --count "${baseBranch}..HEAD"`, worktreePath).trim();
|
|
1947
|
+
return Number.parseInt(count, 10) > 0;
|
|
1948
|
+
} catch {
|
|
1949
|
+
return false;
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
commitChanges(worktreePath, message, baseBranch) {
|
|
1953
|
+
const hasUncommittedChanges = this.hasChanges(worktreePath);
|
|
1954
|
+
if (!hasUncommittedChanges) {
|
|
1955
|
+
if (baseBranch && this.hasCommitsAhead(worktreePath, baseBranch)) {
|
|
1956
|
+
const hash2 = this.git("rev-parse HEAD", worktreePath).trim();
|
|
1957
|
+
this.log(`Agent already committed changes (${hash2.slice(0, 8)}); skipping additional commit`, "info");
|
|
1958
|
+
return hash2;
|
|
1959
|
+
}
|
|
1943
1960
|
this.log("No changes to commit", "info");
|
|
1944
1961
|
return null;
|
|
1945
1962
|
}
|
|
1946
1963
|
this.git("add -A", worktreePath);
|
|
1964
|
+
const staged = this.git("diff --cached --name-only", worktreePath).trim();
|
|
1965
|
+
if (!staged) {
|
|
1966
|
+
this.log("No changes to commit", "info");
|
|
1967
|
+
return null;
|
|
1968
|
+
}
|
|
1947
1969
|
this.gitExec(["commit", "-m", message], worktreePath);
|
|
1948
1970
|
const hash = this.git("rev-parse HEAD", worktreePath).trim();
|
|
1949
1971
|
this.log(`Committed: ${hash.slice(0, 8)}`, "success");
|
|
@@ -1966,8 +1988,8 @@ class WorktreeManager {
|
|
|
1966
1988
|
} catch {}
|
|
1967
1989
|
this.gitExec(["push", "--force-with-lease", "-u", remote, branch], worktreePath);
|
|
1968
1990
|
this.log(`Pushed ${branch} to ${remote} with --force-with-lease`, "success");
|
|
1991
|
+
return branch;
|
|
1969
1992
|
}
|
|
1970
|
-
return branch;
|
|
1971
1993
|
}
|
|
1972
1994
|
getBranch(worktreePath) {
|
|
1973
1995
|
return this.git("rev-parse --abbrev-ref HEAD", worktreePath).trim();
|
|
@@ -2193,7 +2215,9 @@ ${comment.text}
|
|
|
2193
2215
|
prompt += `## Instructions
|
|
2194
2216
|
1. Complete this task.
|
|
2195
2217
|
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.
|
|
2196
|
-
3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...)
|
|
2218
|
+
3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
|
|
2219
|
+
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.
|
|
2220
|
+
5. **Progress**: Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically.`;
|
|
2197
2221
|
return prompt;
|
|
2198
2222
|
}
|
|
2199
2223
|
async buildGenericPrompt(query) {
|
|
@@ -2260,7 +2284,9 @@ There is an index file in the .locus/codebase-index.json and if you need you can
|
|
|
2260
2284
|
}
|
|
2261
2285
|
prompt += `## Instructions
|
|
2262
2286
|
1. Execute the prompt based on the provided project context.
|
|
2263
|
-
2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...)
|
|
2287
|
+
2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
|
|
2288
|
+
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.
|
|
2289
|
+
4. **Progress**: Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically.`;
|
|
2264
2290
|
return prompt;
|
|
2265
2291
|
}
|
|
2266
2292
|
getProjectConfig() {
|
|
@@ -2523,7 +2549,7 @@ class AgentWorker {
|
|
|
2523
2549
|
executor: taskExecutor
|
|
2524
2550
|
};
|
|
2525
2551
|
}
|
|
2526
|
-
commitAndPushWorktree(worktreePath, task) {
|
|
2552
|
+
commitAndPushWorktree(worktreePath, task, baseBranch) {
|
|
2527
2553
|
if (!this.worktreeManager) {
|
|
2528
2554
|
return { branch: null, pushed: false, pushFailed: false };
|
|
2529
2555
|
}
|
|
@@ -2540,7 +2566,7 @@ class AgentWorker {
|
|
|
2540
2566
|
|
|
2541
2567
|
${trailers.join(`
|
|
2542
2568
|
`)}`;
|
|
2543
|
-
const hash = this.worktreeManager.commitChanges(worktreePath, commitMessage);
|
|
2569
|
+
const hash = this.worktreeManager.commitChanges(worktreePath, commitMessage, baseBranch);
|
|
2544
2570
|
if (!hash) {
|
|
2545
2571
|
this.log("No changes to commit for this task", "info");
|
|
2546
2572
|
return {
|
|
@@ -2630,7 +2656,7 @@ ${trailers.join(`
|
|
|
2630
2656
|
let prError = null;
|
|
2631
2657
|
let noChanges = false;
|
|
2632
2658
|
if (result.success && worktreePath) {
|
|
2633
|
-
const commitResult = this.commitAndPushWorktree(worktreePath, fullTask);
|
|
2659
|
+
const commitResult = this.commitAndPushWorktree(worktreePath, fullTask, baseBranch ?? undefined);
|
|
2634
2660
|
taskBranch = commitResult.branch;
|
|
2635
2661
|
branchPushed = commitResult.pushed;
|
|
2636
2662
|
keepBranch = taskBranch !== null;
|
package/dist/core/config.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const LOCUS_CONFIG: {
|
|
|
24
24
|
projectContextFile: string;
|
|
25
25
|
projectProgressFile: string;
|
|
26
26
|
};
|
|
27
|
-
export declare const LOCUS_GITIGNORE_PATTERNS: readonly ["# Locus AI - Session data (user-specific, can grow large)", ".locus/sessions/", "", "# Locus AI - Artifacts (local-only, user-specific)", ".locus/artifacts/", "", "# Locus AI - Review reports (generated per sprint)", ".locus/reviews/", "", "# Locus AI - Plans (generated per task)", ".locus/plans/", "", "# Locus AI - Agent worktrees (parallel execution)", ".locus-worktrees/", "", "# Locus AI - Settings (contains API key, telegram config, etc.)", ".locus/settings.json", "", "# Locus AI - Configuration (contains project context, progress, etc.)", ".locus/config.json"];
|
|
27
|
+
export declare const LOCUS_GITIGNORE_PATTERNS: readonly ["# Locus AI - Session data (user-specific, can grow large)", ".locus/sessions/", "", "# Locus AI - Artifacts (local-only, user-specific)", ".locus/artifacts/", "", "# Locus AI - Review reports (generated per sprint)", ".locus/reviews/", "", "# Locus AI - Plans (generated per task)", ".locus/plans/", "", "# Locus AI - Agent worktrees (parallel execution)", ".locus-worktrees/", "", "# Locus AI - Settings (contains API key, telegram config, etc.)", ".locus/settings.json", "", "# Locus AI - Configuration (contains project context, progress, etc.)", ".locus/config.json", "", "# Locus AI - Project progress (contains project progress, etc.)", ".locus/project/progress.md"];
|
|
28
28
|
export declare function getLocusPath(projectPath: string, fileName: keyof typeof LOCUS_CONFIG): string;
|
|
29
29
|
/**
|
|
30
30
|
* Gets the artifacts directory path for a specific agent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;CAGX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAEhE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAGlD,CAAC;AAEF,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AAEnE,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;CAcxB,CAAC;AAIF,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;CAGX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAEhE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAGlD,CAAC;AAEF,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AAEnE,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;CAcxB,CAAC;AAIF,eAAO,MAAM,wBAAwB,6qBAwB3B,CAAC;AAEX,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,OAAO,YAAY,GAClC,MAAM,CAWR;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,MAAM,CASR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/core/prompt-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGrD,qBAAa,aAAa;IACZ,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,MAAM;IAEjC,KAAK,CACT,IAAI,EAAE,IAAI,EACV,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GACrC,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/core/prompt-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGrD,qBAAa,aAAa;IACZ,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,MAAM;IAEjC,KAAK,CACT,IAAI,EAAE,IAAI,EACV,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GACrC,OAAO,CAAC,MAAM,CAAC;IA+HZ,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4DxD,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,mBAAmB;IAuB3B,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,GAAG,MAAM,GAAG,IAAI;CAoBtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-utils.d.ts","sourceRoot":"","sources":["../../src/git/git-utils.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAE3E;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAUxC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAW3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAU7C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CASxE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,SAAW,GAChB,MAAM,GAAG,IAAI,CAUf;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAM5D;
|
|
1
|
+
{"version":3,"file":"git-utils.d.ts","sourceRoot":"","sources":["../../src/git/git-utils.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAE3E;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAUxC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAW3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAU7C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CASxE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,SAAW,GAChB,MAAM,GAAG,IAAI,CAUf;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAM5D;AAGD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,MAAM,SAAW,GAChB,MAAM,CAsCR"}
|
package/dist/index-node.js
CHANGED
|
@@ -532,7 +532,10 @@ var LOCUS_GITIGNORE_PATTERNS = [
|
|
|
532
532
|
".locus/settings.json",
|
|
533
533
|
"",
|
|
534
534
|
"# Locus AI - Configuration (contains project context, progress, etc.)",
|
|
535
|
-
".locus/config.json"
|
|
535
|
+
".locus/config.json",
|
|
536
|
+
"",
|
|
537
|
+
"# Locus AI - Project progress (contains project progress, etc.)",
|
|
538
|
+
".locus/project/progress.md"
|
|
536
539
|
];
|
|
537
540
|
function getLocusPath(projectPath, fileName) {
|
|
538
541
|
if (fileName === "projectContextFile" || fileName === "projectProgressFile") {
|
|
@@ -1938,12 +1941,31 @@ class WorktreeManager {
|
|
|
1938
1941
|
const status = this.git("status --porcelain", worktreePath).trim();
|
|
1939
1942
|
return status.length > 0;
|
|
1940
1943
|
}
|
|
1941
|
-
|
|
1942
|
-
|
|
1944
|
+
hasCommitsAhead(worktreePath, baseBranch) {
|
|
1945
|
+
try {
|
|
1946
|
+
const count = this.git(`rev-list --count "${baseBranch}..HEAD"`, worktreePath).trim();
|
|
1947
|
+
return Number.parseInt(count, 10) > 0;
|
|
1948
|
+
} catch {
|
|
1949
|
+
return false;
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
commitChanges(worktreePath, message, baseBranch) {
|
|
1953
|
+
const hasUncommittedChanges = this.hasChanges(worktreePath);
|
|
1954
|
+
if (!hasUncommittedChanges) {
|
|
1955
|
+
if (baseBranch && this.hasCommitsAhead(worktreePath, baseBranch)) {
|
|
1956
|
+
const hash2 = this.git("rev-parse HEAD", worktreePath).trim();
|
|
1957
|
+
this.log(`Agent already committed changes (${hash2.slice(0, 8)}); skipping additional commit`, "info");
|
|
1958
|
+
return hash2;
|
|
1959
|
+
}
|
|
1943
1960
|
this.log("No changes to commit", "info");
|
|
1944
1961
|
return null;
|
|
1945
1962
|
}
|
|
1946
1963
|
this.git("add -A", worktreePath);
|
|
1964
|
+
const staged = this.git("diff --cached --name-only", worktreePath).trim();
|
|
1965
|
+
if (!staged) {
|
|
1966
|
+
this.log("No changes to commit", "info");
|
|
1967
|
+
return null;
|
|
1968
|
+
}
|
|
1947
1969
|
this.gitExec(["commit", "-m", message], worktreePath);
|
|
1948
1970
|
const hash = this.git("rev-parse HEAD", worktreePath).trim();
|
|
1949
1971
|
this.log(`Committed: ${hash.slice(0, 8)}`, "success");
|
|
@@ -1966,8 +1988,8 @@ class WorktreeManager {
|
|
|
1966
1988
|
} catch {}
|
|
1967
1989
|
this.gitExec(["push", "--force-with-lease", "-u", remote, branch], worktreePath);
|
|
1968
1990
|
this.log(`Pushed ${branch} to ${remote} with --force-with-lease`, "success");
|
|
1991
|
+
return branch;
|
|
1969
1992
|
}
|
|
1970
|
-
return branch;
|
|
1971
1993
|
}
|
|
1972
1994
|
getBranch(worktreePath) {
|
|
1973
1995
|
return this.git("rev-parse --abbrev-ref HEAD", worktreePath).trim();
|
|
@@ -2193,7 +2215,9 @@ ${comment.text}
|
|
|
2193
2215
|
prompt += `## Instructions
|
|
2194
2216
|
1. Complete this task.
|
|
2195
2217
|
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.
|
|
2196
|
-
3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...)
|
|
2218
|
+
3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
|
|
2219
|
+
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.
|
|
2220
|
+
5. **Progress**: Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically.`;
|
|
2197
2221
|
return prompt;
|
|
2198
2222
|
}
|
|
2199
2223
|
async buildGenericPrompt(query) {
|
|
@@ -2260,7 +2284,9 @@ There is an index file in the .locus/codebase-index.json and if you need you can
|
|
|
2260
2284
|
}
|
|
2261
2285
|
prompt += `## Instructions
|
|
2262
2286
|
1. Execute the prompt based on the provided project context.
|
|
2263
|
-
2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...)
|
|
2287
|
+
2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
|
|
2288
|
+
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.
|
|
2289
|
+
4. **Progress**: Do NOT modify \`.locus/project/progress.md\`. The system updates it automatically.`;
|
|
2264
2290
|
return prompt;
|
|
2265
2291
|
}
|
|
2266
2292
|
getProjectConfig() {
|
|
@@ -2523,7 +2549,7 @@ class AgentWorker {
|
|
|
2523
2549
|
executor: taskExecutor
|
|
2524
2550
|
};
|
|
2525
2551
|
}
|
|
2526
|
-
commitAndPushWorktree(worktreePath, task) {
|
|
2552
|
+
commitAndPushWorktree(worktreePath, task, baseBranch) {
|
|
2527
2553
|
if (!this.worktreeManager) {
|
|
2528
2554
|
return { branch: null, pushed: false, pushFailed: false };
|
|
2529
2555
|
}
|
|
@@ -2540,7 +2566,7 @@ class AgentWorker {
|
|
|
2540
2566
|
|
|
2541
2567
|
${trailers.join(`
|
|
2542
2568
|
`)}`;
|
|
2543
|
-
const hash = this.worktreeManager.commitChanges(worktreePath, commitMessage);
|
|
2569
|
+
const hash = this.worktreeManager.commitChanges(worktreePath, commitMessage, baseBranch);
|
|
2544
2570
|
if (!hash) {
|
|
2545
2571
|
this.log("No changes to commit for this task", "info");
|
|
2546
2572
|
return {
|
|
@@ -2630,7 +2656,7 @@ ${trailers.join(`
|
|
|
2630
2656
|
let prError = null;
|
|
2631
2657
|
let noChanges = false;
|
|
2632
2658
|
if (result.success && worktreePath) {
|
|
2633
|
-
const commitResult = this.commitAndPushWorktree(worktreePath, fullTask);
|
|
2659
|
+
const commitResult = this.commitAndPushWorktree(worktreePath, fullTask, baseBranch ?? undefined);
|
|
2634
2660
|
taskBranch = commitResult.branch;
|
|
2635
2661
|
branchPushed = commitResult.pushed;
|
|
2636
2662
|
keepBranch = taskBranch !== null;
|
|
@@ -50,14 +50,25 @@ export declare class WorktreeManager {
|
|
|
50
50
|
* Check if a worktree has uncommitted changes.
|
|
51
51
|
*/
|
|
52
52
|
hasChanges(worktreePath: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Check if a worktree has commits ahead of the base branch.
|
|
55
|
+
* This detects changes that the AI agent committed during execution.
|
|
56
|
+
*/
|
|
57
|
+
hasCommitsAhead(worktreePath: string, baseBranch: string): boolean;
|
|
53
58
|
/**
|
|
54
59
|
* Stage all changes and commit in a worktree.
|
|
55
60
|
* Returns the commit hash, or null if there were no changes to commit.
|
|
61
|
+
*
|
|
62
|
+
* When `baseBranch` is provided, also checks for commits already made by
|
|
63
|
+
* the AI agent during execution. If there are no uncommitted changes but
|
|
64
|
+
* the branch has diverged from the base, returns the current HEAD hash
|
|
65
|
+
* without creating a new commit.
|
|
56
66
|
*/
|
|
57
|
-
commitChanges(worktreePath: string, message: string): string | null;
|
|
67
|
+
commitChanges(worktreePath: string, message: string, baseBranch?: string): string | null;
|
|
58
68
|
/**
|
|
59
69
|
* Push a worktree's branch to a remote.
|
|
60
70
|
* Returns the branch name on success, or throws on failure.
|
|
71
|
+
* Expects the remote to be an HTTPS URL with `gh auth setup-git` configured.
|
|
61
72
|
*/
|
|
62
73
|
pushBranch(worktreePath: string, remote?: string): string;
|
|
63
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-manager.d.ts","sourceRoot":"","sources":["../../src/worktree/worktree-manager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAEzB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAQ;gBAGjB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAChC,GAAG,CAAC,EAAE,KAAK;IAOb;;OAEG;IACH,OAAO,KAAK,QAAQ,GAEnB;IAED;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAUzD;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB;IAmF5D;;;OAGG;IACH,IAAI,IAAI,YAAY,EAAE;IA+CtB;;OAEG;IACH,kBAAkB,IAAI,YAAY,EAAE;IAIpC;;OAEG;IACH,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,UAAO,GAAG,IAAI;IAsCvD;;OAEG;IACH,KAAK,IAAI,MAAM;IAmBf;;;OAGG;IACH,SAAS,IAAI,MAAM;IAyBnB;;OAEG;IACH,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAKzC;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"worktree-manager.d.ts","sourceRoot":"","sources":["../../src/worktree/worktree-manager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CA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IvC;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAM3C;;OAEG;IACH,OAAO,CAAC,YAAY;IAYpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,qBAAqB;IA0B7B,OAAO,CAAC,yBAAyB;IASjC;;OAEG;IACH,OAAO,CAAC,GAAG;IAQX;;OAEG;IACH,OAAO,CAAC,OAAO;CAOhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locusai/sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"clean": "rm -rf node_modules"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@locusai/shared": "^0.9.
|
|
33
|
+
"@locusai/shared": "^0.9.12",
|
|
34
34
|
"axios": "^1.13.2",
|
|
35
35
|
"events": "^3.3.0",
|
|
36
36
|
"globby": "^14.0.2"
|