brainctl 0.1.0 → 0.1.2

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/cli.d.ts CHANGED
@@ -12,3 +12,4 @@ export interface CliServices {
12
12
  }
13
13
  export declare function createProgram(overrides?: Partial<CliServices>): Command;
14
14
  export declare function main(argv?: string[]): Promise<void>;
15
+ export declare function shouldRunMain(entryPointPath: string | undefined, moduleUrl: string): boolean;
package/dist/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from 'node:fs';
2
3
  import path from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
4
5
  import { Command } from 'commander';
@@ -35,6 +36,12 @@ export async function main(argv = process.argv) {
35
36
  process.exitCode = 1;
36
37
  }
37
38
  }
39
+ export function shouldRunMain(entryPointPath, moduleUrl) {
40
+ if (!entryPointPath) {
41
+ return false;
42
+ }
43
+ return resolveRealPath(entryPointPath) === resolveRealPath(fileURLToPath(moduleUrl));
44
+ }
38
45
  function createDefaultServices(overrides) {
39
46
  const resolver = createExecutorResolver();
40
47
  return {
@@ -45,8 +52,15 @@ function createDefaultServices(overrides) {
45
52
  ...overrides
46
53
  };
47
54
  }
48
- const entryPointPath = process.argv[1] ? path.resolve(process.argv[1]) : '';
49
- const currentFilePath = fileURLToPath(import.meta.url);
50
- if (entryPointPath === currentFilePath) {
55
+ if (shouldRunMain(process.argv[1], import.meta.url)) {
51
56
  void main();
52
57
  }
58
+ function resolveRealPath(targetPath) {
59
+ const resolvedPath = path.resolve(targetPath);
60
+ try {
61
+ return realpathSync(resolvedPath);
62
+ }
63
+ catch {
64
+ return resolvedPath;
65
+ }
66
+ }
@@ -1,4 +1,11 @@
1
1
  import type { Executor, ExecutorRunOptions, ExecutorResult } from './types.js';
2
+ export declare function createClaudeInvocation(context: string, options?: ExecutorRunOptions): {
3
+ command: string;
4
+ args: string[];
5
+ agent: "claude";
6
+ context: string;
7
+ runOptions: ExecutorRunOptions | undefined;
8
+ };
2
9
  export declare class ClaudeExecutor implements Executor {
3
10
  readonly agent: "claude";
4
11
  run(context: string, options?: ExecutorRunOptions): Promise<ExecutorResult>;
@@ -1,12 +1,16 @@
1
1
  import { runAgentProcess } from './process.js';
2
+ export function createClaudeInvocation(context, options) {
3
+ return {
4
+ command: 'claude',
5
+ args: ['-p'],
6
+ agent: 'claude',
7
+ context,
8
+ runOptions: options
9
+ };
10
+ }
2
11
  export class ClaudeExecutor {
3
12
  agent = 'claude';
4
13
  async run(context, options) {
5
- return await runAgentProcess({
6
- command: 'claude',
7
- agent: this.agent,
8
- context,
9
- runOptions: options
10
- });
14
+ return await runAgentProcess(createClaudeInvocation(context, options));
11
15
  }
12
16
  }
@@ -1,4 +1,11 @@
1
1
  import type { Executor, ExecutorRunOptions, ExecutorResult } from './types.js';
2
+ export declare function createCodexInvocation(context: string, options?: ExecutorRunOptions): {
3
+ command: string;
4
+ args: string[];
5
+ agent: "codex";
6
+ context: string;
7
+ runOptions: ExecutorRunOptions | undefined;
8
+ };
2
9
  export declare class CodexExecutor implements Executor {
3
10
  readonly agent: "codex";
4
11
  run(context: string, options?: ExecutorRunOptions): Promise<ExecutorResult>;
@@ -1,12 +1,16 @@
1
1
  import { runAgentProcess } from './process.js';
2
+ export function createCodexInvocation(context, options) {
3
+ return {
4
+ command: 'codex',
5
+ args: ['exec', '--skip-git-repo-check', '-'],
6
+ agent: 'codex',
7
+ context,
8
+ runOptions: options
9
+ };
10
+ }
2
11
  export class CodexExecutor {
3
12
  agent = 'codex';
4
13
  async run(context, options) {
5
- return await runAgentProcess({
6
- command: 'codex',
7
- agent: this.agent,
8
- context,
9
- runOptions: options
10
- });
14
+ return await runAgentProcess(createCodexInvocation(context, options));
11
15
  }
12
16
  }
@@ -2,6 +2,7 @@ import type { AgentName } from '../types.js';
2
2
  import type { ExecutorResult, ExecutorRunOptions } from './types.js';
3
3
  interface RunAgentProcessOptions {
4
4
  command: string;
5
+ args?: string[];
5
6
  agent: AgentName;
6
7
  context: string;
7
8
  runOptions?: ExecutorRunOptions;
@@ -2,7 +2,7 @@ import { spawn } from 'node:child_process';
2
2
  import { ExecutionError } from '../errors.js';
3
3
  export async function runAgentProcess(options) {
4
4
  return await new Promise((resolve, reject) => {
5
- const child = spawn(options.command, [], {
5
+ const child = spawn(options.command, options.args ?? [], {
6
6
  stdio: ['pipe', 'pipe', 'pipe']
7
7
  });
8
8
  let output = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainctl",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "CLI environment manager for consistent AI workflows",
5
5
  "type": "module",
6
6
  "repository": {