@locusai/cli 0.7.1 → 0.7.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.
@@ -17227,7 +17227,6 @@ class ClaudeRunner {
17227
17227
  if (type === "content_block_start" && content_block) {
17228
17228
  if (content_block.type === "tool_use" && content_block.name) {
17229
17229
  this.log?.(`
17230
-
17231
17230
  ${c.primary("[Claude]")} ${c.bold(`Running ${content_block.name}...`)}
17232
17231
  `, "info");
17233
17232
  }
@@ -36526,6 +36525,76 @@ ${comment.text}
36526
36525
  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.
36527
36526
  3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
36528
36527
  4. When finished successfully, output: <promise>COMPLETE</promise>
36528
+ `;
36529
+ return prompt;
36530
+ }
36531
+ async buildGenericPrompt(query) {
36532
+ let prompt = `# Direct Execution
36533
+
36534
+ `;
36535
+ prompt += `## Prompt
36536
+ ${query}
36537
+
36538
+ `;
36539
+ const projectConfig = this.getProjectConfig();
36540
+ if (projectConfig) {
36541
+ prompt += `## Project Metadata
36542
+ `;
36543
+ prompt += `- Version: ${projectConfig.version || "Unknown"}
36544
+ `;
36545
+ prompt += `- Created At: ${projectConfig.createdAt || "Unknown"}
36546
+
36547
+ `;
36548
+ }
36549
+ const contextPath = getLocusPath(this.projectPath, "contextFile");
36550
+ let hasLocalContext = false;
36551
+ if (existsSync4(contextPath)) {
36552
+ try {
36553
+ const context = readFileSync4(contextPath, "utf-8");
36554
+ if (context.trim().length > 20) {
36555
+ prompt += `## Project Context (Local)
36556
+ ${context}
36557
+
36558
+ `;
36559
+ hasLocalContext = true;
36560
+ }
36561
+ } catch (err) {
36562
+ console.warn(`Warning: Could not read context file: ${err}`);
36563
+ }
36564
+ }
36565
+ if (!hasLocalContext) {
36566
+ const fallback = this.getFallbackContext();
36567
+ if (fallback) {
36568
+ prompt += `## Project Context (README Fallback)
36569
+ ${fallback}
36570
+
36571
+ `;
36572
+ }
36573
+ }
36574
+ prompt += this.getProjectStructure();
36575
+ prompt += this.getSkillsInfo();
36576
+ prompt += `## Project Knowledge Base
36577
+ `;
36578
+ prompt += `You have access to the following documentation directories for context:
36579
+ `;
36580
+ prompt += `- Artifacts: \`.locus/artifacts\`
36581
+ `;
36582
+ prompt += `- Documents: \`.locus/documents\`
36583
+ `;
36584
+ prompt += `If you need more information about the project strategies, plans, or architecture, please read files in these directories.
36585
+
36586
+ `;
36587
+ const indexPath = getLocusPath(this.projectPath, "indexFile");
36588
+ if (existsSync4(indexPath)) {
36589
+ prompt += `## Codebase Overview
36590
+ There is an index file in the .locus/codebase-index.json and if you need you can check it.
36591
+
36592
+ `;
36593
+ }
36594
+ prompt += `## Instructions
36595
+ 1. Execute the prompt based on the provided project context.
36596
+ 2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
36597
+ 3. When finished successfully, output: <promise>COMPLETE</promise>
36529
36598
  `;
36530
36599
  return prompt;
36531
36600
  }
package/bin/locus.js CHANGED
@@ -32355,6 +32355,76 @@ ${comment.text}
32355
32355
  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.
32356
32356
  3. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
32357
32357
  4. When finished successfully, output: <promise>COMPLETE</promise>
32358
+ `;
32359
+ return prompt;
32360
+ }
32361
+ async buildGenericPrompt(query) {
32362
+ let prompt = `# Direct Execution
32363
+
32364
+ `;
32365
+ prompt += `## Prompt
32366
+ ${query}
32367
+
32368
+ `;
32369
+ const projectConfig = this.getProjectConfig();
32370
+ if (projectConfig) {
32371
+ prompt += `## Project Metadata
32372
+ `;
32373
+ prompt += `- Version: ${projectConfig.version || "Unknown"}
32374
+ `;
32375
+ prompt += `- Created At: ${projectConfig.createdAt || "Unknown"}
32376
+
32377
+ `;
32378
+ }
32379
+ const contextPath = getLocusPath(this.projectPath, "contextFile");
32380
+ let hasLocalContext = false;
32381
+ if (existsSync3(contextPath)) {
32382
+ try {
32383
+ const context = readFileSync3(contextPath, "utf-8");
32384
+ if (context.trim().length > 20) {
32385
+ prompt += `## Project Context (Local)
32386
+ ${context}
32387
+
32388
+ `;
32389
+ hasLocalContext = true;
32390
+ }
32391
+ } catch (err) {
32392
+ console.warn(`Warning: Could not read context file: ${err}`);
32393
+ }
32394
+ }
32395
+ if (!hasLocalContext) {
32396
+ const fallback = this.getFallbackContext();
32397
+ if (fallback) {
32398
+ prompt += `## Project Context (README Fallback)
32399
+ ${fallback}
32400
+
32401
+ `;
32402
+ }
32403
+ }
32404
+ prompt += this.getProjectStructure();
32405
+ prompt += this.getSkillsInfo();
32406
+ prompt += `## Project Knowledge Base
32407
+ `;
32408
+ prompt += `You have access to the following documentation directories for context:
32409
+ `;
32410
+ prompt += `- Artifacts: \`.locus/artifacts\`
32411
+ `;
32412
+ prompt += `- Documents: \`.locus/documents\`
32413
+ `;
32414
+ prompt += `If you need more information about the project strategies, plans, or architecture, please read files in these directories.
32415
+
32416
+ `;
32417
+ const indexPath = getLocusPath(this.projectPath, "indexFile");
32418
+ if (existsSync3(indexPath)) {
32419
+ prompt += `## Codebase Overview
32420
+ There is an index file in the .locus/codebase-index.json and if you need you can check it.
32421
+
32422
+ `;
32423
+ }
32424
+ prompt += `## Instructions
32425
+ 1. Execute the prompt based on the provided project context.
32426
+ 2. **Paths**: Use relative paths from the project root at all times. Do NOT use absolute local paths (e.g., /Users/...).
32427
+ 3. When finished successfully, output: <promise>COMPLETE</promise>
32358
32428
  `;
32359
32429
  return prompt;
32360
32430
  }
@@ -32721,7 +32791,6 @@ class ClaudeRunner {
32721
32791
  if (type === "content_block_start" && content_block) {
32722
32792
  if (content_block.type === "tool_use" && content_block.name) {
32723
32793
  this.log?.(`
32724
-
32725
32794
  ${c.primary("[Claude]")} ${c.bold(`Running ${content_block.name}...`)}
32726
32795
  `, "info");
32727
32796
  }
@@ -37767,6 +37836,47 @@ async function indexCommand(args) {
37767
37836
  ${c.success("✔")} ${c.success("Indexing complete!")}
37768
37837
  `);
37769
37838
  }
37839
+ async function execCommand(args) {
37840
+ const { values, positionals } = parseArgs({
37841
+ args,
37842
+ options: {
37843
+ model: { type: "string" },
37844
+ provider: { type: "string" },
37845
+ dir: { type: "string" }
37846
+ },
37847
+ strict: false
37848
+ });
37849
+ const promptInput = positionals.join(" ");
37850
+ if (!promptInput) {
37851
+ console.error(c.error('Error: Prompt is required. Usage: locus exec "your prompt"'));
37852
+ process.exit(1);
37853
+ }
37854
+ const projectPath = values.dir || process.cwd();
37855
+ requireInitialization(projectPath, "exec");
37856
+ const provider = resolveProvider2(values.provider);
37857
+ const model = values.model || DEFAULT_MODEL[provider];
37858
+ const aiRunner = createAiRunner(provider, {
37859
+ projectPath,
37860
+ model
37861
+ });
37862
+ const builder = new PromptBuilder(projectPath);
37863
+ const fullPrompt = await builder.buildGenericPrompt(promptInput);
37864
+ console.log(`
37865
+ ${c.primary("\uD83D\uDE80")} ${c.bold("Executing prompt with repository context...")}
37866
+ `);
37867
+ try {
37868
+ const result = await aiRunner.run(fullPrompt);
37869
+ console.log(result);
37870
+ console.log(`
37871
+ ${c.success("✔")} ${c.success("Execution finished!")}
37872
+ `);
37873
+ } catch (error48) {
37874
+ console.error(`
37875
+ ${c.error("✖")} ${c.error("Execution failed:")} ${c.red(error48 instanceof Error ? error48.message : String(error48))}
37876
+ `);
37877
+ process.exit(1);
37878
+ }
37879
+ }
37770
37880
  async function initCommand() {
37771
37881
  const projectPath = process.cwd();
37772
37882
  if (isProjectInitialized(projectPath)) {
@@ -37810,6 +37920,9 @@ async function main() {
37810
37920
  case "init":
37811
37921
  await initCommand();
37812
37922
  break;
37923
+ case "exec":
37924
+ await execCommand(args);
37925
+ break;
37813
37926
  default:
37814
37927
  console.log(`
37815
37928
  ${c.header(" USAGE ")}
@@ -37819,6 +37932,7 @@ async function main() {
37819
37932
  ${c.success("init")} Initialize Locus in the current directory
37820
37933
  ${c.success("index")} Index the codebase for AI context
37821
37934
  ${c.success("run")} Start an agent to work on tasks
37935
+ ${c.success("exec")} Run a prompt with repository context
37822
37936
 
37823
37937
  ${c.header(" OPTIONS ")}
37824
37938
  ${c.secondary("--help")} Show this help message
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusai/cli",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
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.7.1"
35
+ "@locusai/sdk": "^0.7.3"
36
36
  },
37
37
  "devDependencies": {}
38
38
  }