@locusai/sdk 0.21.7 → 0.21.9
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/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/index.cjs +183 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +141 -0
- package/dist/invoke.d.ts +56 -0
- package/dist/invoke.d.ts.map +1 -0
- package/dist/logger.d.ts +50 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/types.d.ts +110 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locus config reader for community package authors.
|
|
3
|
+
*
|
|
4
|
+
* Reads `~/.locus/config.json` (global overrides) and
|
|
5
|
+
* `{cwd}/.locus/config.json` (project config), merges them, and returns
|
|
6
|
+
* a single {@link LocusConfig} object. Never throws — missing files are
|
|
7
|
+
* treated as empty and a safe default config is returned instead.
|
|
8
|
+
*/
|
|
9
|
+
import type { LocusConfig } from "./types.js";
|
|
10
|
+
export declare const DEFAULT_CONFIG: LocusConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Read and merge the Locus configuration.
|
|
13
|
+
*
|
|
14
|
+
* Looks in two places (in priority order, lowest to highest):
|
|
15
|
+
* 1. `~/.locus/config.json` — global user overrides
|
|
16
|
+
* 2. `{cwd}/.locus/config.json` — project-level config
|
|
17
|
+
*
|
|
18
|
+
* Missing files are silently ignored. If neither file exists the returned
|
|
19
|
+
* object contains only the built-in defaults.
|
|
20
|
+
*
|
|
21
|
+
* @param cwd - Working directory to look for `.locus/config.json`.
|
|
22
|
+
* Defaults to `process.cwd()`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readLocusConfig(cwd?: string): LocusConfig;
|
|
25
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C,eAAO,MAAM,cAAc,EAAE,WAiC5B,CAAC;AAmDF;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAezD"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/index.ts
|
|
40
|
+
var exports_src = {};
|
|
41
|
+
__export(exports_src, {
|
|
42
|
+
readLocusConfig: () => readLocusConfig,
|
|
43
|
+
invokeLocusStream: () => invokeLocusStream,
|
|
44
|
+
invokeLocus: () => invokeLocus,
|
|
45
|
+
createLogger: () => createLogger,
|
|
46
|
+
DEFAULT_CONFIG: () => DEFAULT_CONFIG
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(exports_src);
|
|
49
|
+
|
|
50
|
+
// src/config.ts
|
|
51
|
+
var import_node_fs = require("node:fs");
|
|
52
|
+
var import_node_os = require("node:os");
|
|
53
|
+
var import_node_path = require("node:path");
|
|
54
|
+
var DEFAULT_CONFIG = {
|
|
55
|
+
version: "0.21.7",
|
|
56
|
+
github: {
|
|
57
|
+
owner: "",
|
|
58
|
+
repo: "",
|
|
59
|
+
defaultBranch: "main"
|
|
60
|
+
},
|
|
61
|
+
ai: {
|
|
62
|
+
provider: "claude",
|
|
63
|
+
model: "claude-sonnet-4-6"
|
|
64
|
+
},
|
|
65
|
+
agent: {
|
|
66
|
+
maxParallel: 3,
|
|
67
|
+
autoLabel: true,
|
|
68
|
+
autoPR: true,
|
|
69
|
+
baseBranch: "main",
|
|
70
|
+
rebaseBeforeTask: true
|
|
71
|
+
},
|
|
72
|
+
sprint: {
|
|
73
|
+
active: null,
|
|
74
|
+
stopOnFailure: true
|
|
75
|
+
},
|
|
76
|
+
logging: {
|
|
77
|
+
level: "normal",
|
|
78
|
+
maxFiles: 20,
|
|
79
|
+
maxTotalSizeMB: 50
|
|
80
|
+
},
|
|
81
|
+
sandbox: {
|
|
82
|
+
enabled: true,
|
|
83
|
+
providers: {},
|
|
84
|
+
extraWorkspaces: [],
|
|
85
|
+
readOnlyPaths: []
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function readJsonFile(filePath) {
|
|
89
|
+
if (!import_node_fs.existsSync(filePath))
|
|
90
|
+
return null;
|
|
91
|
+
try {
|
|
92
|
+
const raw = import_node_fs.readFileSync(filePath, "utf-8");
|
|
93
|
+
const parsed = JSON.parse(raw);
|
|
94
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
95
|
+
return parsed;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function deepMerge(target, source) {
|
|
103
|
+
const result = { ...target };
|
|
104
|
+
for (const [key, value] of Object.entries(source)) {
|
|
105
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value) && typeof result[key] === "object" && result[key] !== null && !Array.isArray(result[key])) {
|
|
106
|
+
result[key] = deepMerge(result[key], value);
|
|
107
|
+
} else if (value !== undefined) {
|
|
108
|
+
result[key] = value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
function readLocusConfig(cwd) {
|
|
114
|
+
const workingDir = cwd ?? process.cwd();
|
|
115
|
+
const globalPath = import_node_path.join(import_node_os.homedir(), ".locus", "config.json");
|
|
116
|
+
const projectPath = import_node_path.join(workingDir, ".locus", "config.json");
|
|
117
|
+
const globalRaw = readJsonFile(globalPath) ?? {};
|
|
118
|
+
const projectRaw = readJsonFile(projectPath) ?? {};
|
|
119
|
+
const merged = deepMerge(deepMerge(DEFAULT_CONFIG, globalRaw), projectRaw);
|
|
120
|
+
return merged;
|
|
121
|
+
}
|
|
122
|
+
// src/invoke.ts
|
|
123
|
+
var import_node_child_process = require("node:child_process");
|
|
124
|
+
function invokeLocus(args, cwd) {
|
|
125
|
+
return new Promise((resolve) => {
|
|
126
|
+
const result = import_node_child_process.spawnSync("locus", args, {
|
|
127
|
+
cwd: cwd ?? process.cwd(),
|
|
128
|
+
encoding: "utf-8",
|
|
129
|
+
env: process.env,
|
|
130
|
+
shell: false
|
|
131
|
+
});
|
|
132
|
+
resolve({
|
|
133
|
+
stdout: result.stdout ?? "",
|
|
134
|
+
stderr: result.stderr ?? "",
|
|
135
|
+
exitCode: result.status ?? 1
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function invokeLocusStream(args, cwd) {
|
|
140
|
+
return import_node_child_process.spawn("locus", args, {
|
|
141
|
+
cwd: cwd ?? process.cwd(),
|
|
142
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
143
|
+
env: process.env,
|
|
144
|
+
shell: false
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// src/logger.ts
|
|
148
|
+
var colorEnabled = () => process.stderr.isTTY === true && process.env.NO_COLOR === undefined;
|
|
149
|
+
var wrap = (open, close) => (text) => colorEnabled() ? `${open}${text}${close}` : text;
|
|
150
|
+
var bold = wrap("\x1B[1m", "\x1B[22m");
|
|
151
|
+
var dim = wrap("\x1B[2m", "\x1B[22m");
|
|
152
|
+
var red = wrap("\x1B[31m", "\x1B[39m");
|
|
153
|
+
var yellow = wrap("\x1B[33m", "\x1B[39m");
|
|
154
|
+
var cyan = wrap("\x1B[36m", "\x1B[39m");
|
|
155
|
+
var gray = wrap("\x1B[90m", "\x1B[39m");
|
|
156
|
+
function formatData(data) {
|
|
157
|
+
if (!data || Object.keys(data).length === 0)
|
|
158
|
+
return "";
|
|
159
|
+
return ` ${dim(JSON.stringify(data))}`;
|
|
160
|
+
}
|
|
161
|
+
function createLogger(name) {
|
|
162
|
+
const prefix = dim(`[${name}]`);
|
|
163
|
+
return {
|
|
164
|
+
info(msg, data) {
|
|
165
|
+
process.stderr.write(`${bold(cyan("●"))} ${prefix} ${msg}${formatData(data)}
|
|
166
|
+
`);
|
|
167
|
+
},
|
|
168
|
+
warn(msg, data) {
|
|
169
|
+
process.stderr.write(`${bold(yellow("⚠"))} ${prefix} ${yellow(msg)}${formatData(data)}
|
|
170
|
+
`);
|
|
171
|
+
},
|
|
172
|
+
error(msg, data) {
|
|
173
|
+
process.stderr.write(`${bold(red("✗"))} ${prefix} ${red(msg)}${formatData(data)}
|
|
174
|
+
`);
|
|
175
|
+
},
|
|
176
|
+
debug(msg, data) {
|
|
177
|
+
if (!process.env.LOCUS_DEBUG)
|
|
178
|
+
return;
|
|
179
|
+
process.stderr.write(`${gray("⋯")} ${prefix} ${gray(msg)}${formatData(data)}
|
|
180
|
+
`);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @locusai/sdk — SDK for building Locus-compatible community packages.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import {
|
|
7
|
+
* readLocusConfig,
|
|
8
|
+
* invokeLocus,
|
|
9
|
+
* invokeLocusStream,
|
|
10
|
+
* createLogger,
|
|
11
|
+
* } from "@locusai/sdk";
|
|
12
|
+
* import type { LocusConfig, LocusPackageManifest } from "@locusai/sdk";
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export { DEFAULT_CONFIG, readLocusConfig } from "./config.js";
|
|
16
|
+
export type { LocusInvokeResult } from "./invoke.js";
|
|
17
|
+
export { invokeLocus, invokeLocusStream } from "./invoke.js";
|
|
18
|
+
export type { LocusLogger } from "./logger.js";
|
|
19
|
+
export { createLogger } from "./logger.js";
|
|
20
|
+
export type { AIProvider, LocusConfig, LocusPackageManifest } from "./types.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE7D,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
var DEFAULT_CONFIG = {
|
|
6
|
+
version: "0.21.7",
|
|
7
|
+
github: {
|
|
8
|
+
owner: "",
|
|
9
|
+
repo: "",
|
|
10
|
+
defaultBranch: "main"
|
|
11
|
+
},
|
|
12
|
+
ai: {
|
|
13
|
+
provider: "claude",
|
|
14
|
+
model: "claude-sonnet-4-6"
|
|
15
|
+
},
|
|
16
|
+
agent: {
|
|
17
|
+
maxParallel: 3,
|
|
18
|
+
autoLabel: true,
|
|
19
|
+
autoPR: true,
|
|
20
|
+
baseBranch: "main",
|
|
21
|
+
rebaseBeforeTask: true
|
|
22
|
+
},
|
|
23
|
+
sprint: {
|
|
24
|
+
active: null,
|
|
25
|
+
stopOnFailure: true
|
|
26
|
+
},
|
|
27
|
+
logging: {
|
|
28
|
+
level: "normal",
|
|
29
|
+
maxFiles: 20,
|
|
30
|
+
maxTotalSizeMB: 50
|
|
31
|
+
},
|
|
32
|
+
sandbox: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
providers: {},
|
|
35
|
+
extraWorkspaces: [],
|
|
36
|
+
readOnlyPaths: []
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
function readJsonFile(filePath) {
|
|
40
|
+
if (!existsSync(filePath))
|
|
41
|
+
return null;
|
|
42
|
+
try {
|
|
43
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
44
|
+
const parsed = JSON.parse(raw);
|
|
45
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function deepMerge(target, source) {
|
|
54
|
+
const result = { ...target };
|
|
55
|
+
for (const [key, value] of Object.entries(source)) {
|
|
56
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value) && typeof result[key] === "object" && result[key] !== null && !Array.isArray(result[key])) {
|
|
57
|
+
result[key] = deepMerge(result[key], value);
|
|
58
|
+
} else if (value !== undefined) {
|
|
59
|
+
result[key] = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
function readLocusConfig(cwd) {
|
|
65
|
+
const workingDir = cwd ?? process.cwd();
|
|
66
|
+
const globalPath = join(homedir(), ".locus", "config.json");
|
|
67
|
+
const projectPath = join(workingDir, ".locus", "config.json");
|
|
68
|
+
const globalRaw = readJsonFile(globalPath) ?? {};
|
|
69
|
+
const projectRaw = readJsonFile(projectPath) ?? {};
|
|
70
|
+
const merged = deepMerge(deepMerge(DEFAULT_CONFIG, globalRaw), projectRaw);
|
|
71
|
+
return merged;
|
|
72
|
+
}
|
|
73
|
+
// src/invoke.ts
|
|
74
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
75
|
+
function invokeLocus(args, cwd) {
|
|
76
|
+
return new Promise((resolve) => {
|
|
77
|
+
const result = spawnSync("locus", args, {
|
|
78
|
+
cwd: cwd ?? process.cwd(),
|
|
79
|
+
encoding: "utf-8",
|
|
80
|
+
env: process.env,
|
|
81
|
+
shell: false
|
|
82
|
+
});
|
|
83
|
+
resolve({
|
|
84
|
+
stdout: result.stdout ?? "",
|
|
85
|
+
stderr: result.stderr ?? "",
|
|
86
|
+
exitCode: result.status ?? 1
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function invokeLocusStream(args, cwd) {
|
|
91
|
+
return spawn("locus", args, {
|
|
92
|
+
cwd: cwd ?? process.cwd(),
|
|
93
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
94
|
+
env: process.env,
|
|
95
|
+
shell: false
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// src/logger.ts
|
|
99
|
+
var colorEnabled = () => process.stderr.isTTY === true && process.env.NO_COLOR === undefined;
|
|
100
|
+
var wrap = (open, close) => (text) => colorEnabled() ? `${open}${text}${close}` : text;
|
|
101
|
+
var bold = wrap("\x1B[1m", "\x1B[22m");
|
|
102
|
+
var dim = wrap("\x1B[2m", "\x1B[22m");
|
|
103
|
+
var red = wrap("\x1B[31m", "\x1B[39m");
|
|
104
|
+
var yellow = wrap("\x1B[33m", "\x1B[39m");
|
|
105
|
+
var cyan = wrap("\x1B[36m", "\x1B[39m");
|
|
106
|
+
var gray = wrap("\x1B[90m", "\x1B[39m");
|
|
107
|
+
function formatData(data) {
|
|
108
|
+
if (!data || Object.keys(data).length === 0)
|
|
109
|
+
return "";
|
|
110
|
+
return ` ${dim(JSON.stringify(data))}`;
|
|
111
|
+
}
|
|
112
|
+
function createLogger(name) {
|
|
113
|
+
const prefix = dim(`[${name}]`);
|
|
114
|
+
return {
|
|
115
|
+
info(msg, data) {
|
|
116
|
+
process.stderr.write(`${bold(cyan("●"))} ${prefix} ${msg}${formatData(data)}
|
|
117
|
+
`);
|
|
118
|
+
},
|
|
119
|
+
warn(msg, data) {
|
|
120
|
+
process.stderr.write(`${bold(yellow("⚠"))} ${prefix} ${yellow(msg)}${formatData(data)}
|
|
121
|
+
`);
|
|
122
|
+
},
|
|
123
|
+
error(msg, data) {
|
|
124
|
+
process.stderr.write(`${bold(red("✗"))} ${prefix} ${red(msg)}${formatData(data)}
|
|
125
|
+
`);
|
|
126
|
+
},
|
|
127
|
+
debug(msg, data) {
|
|
128
|
+
if (!process.env.LOCUS_DEBUG)
|
|
129
|
+
return;
|
|
130
|
+
process.stderr.write(`${gray("⋯")} ${prefix} ${gray(msg)}${formatData(data)}
|
|
131
|
+
`);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
readLocusConfig,
|
|
137
|
+
invokeLocusStream,
|
|
138
|
+
invokeLocus,
|
|
139
|
+
createLogger,
|
|
140
|
+
DEFAULT_CONFIG
|
|
141
|
+
};
|
package/dist/invoke.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for spawning the `locus` CLI binary from within a community package.
|
|
3
|
+
*
|
|
4
|
+
* Both functions resolve `locus` from the current `PATH`, so the user must
|
|
5
|
+
* have `@locusai/cli` installed globally (or the binary otherwise available).
|
|
6
|
+
*/
|
|
7
|
+
import type { ChildProcess } from "node:child_process";
|
|
8
|
+
/** Result returned by {@link invokeLocus}. */
|
|
9
|
+
export interface LocusInvokeResult {
|
|
10
|
+
/** Captured stdout from the locus process. */
|
|
11
|
+
stdout: string;
|
|
12
|
+
/** Captured stderr from the locus process. */
|
|
13
|
+
stderr: string;
|
|
14
|
+
/** Exit code; `0` indicates success. */
|
|
15
|
+
exitCode: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Spawn `locus` with the given arguments and capture its output.
|
|
19
|
+
*
|
|
20
|
+
* The process inherits the current environment. Resolves when the child
|
|
21
|
+
* process exits.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const result = await invokeLocus(["run", "42"]);
|
|
26
|
+
* if (result.exitCode !== 0) {
|
|
27
|
+
* console.error("locus failed:", result.stderr);
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param args - Arguments to pass after `locus`, e.g. `["run", "42"]`.
|
|
32
|
+
* @param cwd - Working directory for the child process. Defaults to
|
|
33
|
+
* `process.cwd()`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function invokeLocus(args: string[], cwd?: string): Promise<LocusInvokeResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Spawn `locus` with the given arguments and return the raw {@link ChildProcess}
|
|
38
|
+
* for streaming.
|
|
39
|
+
*
|
|
40
|
+
* Unlike {@link invokeLocus} this does **not** buffer output — you can attach
|
|
41
|
+
* listeners to `child.stdout` and `child.stderr` directly, or set `stdio` to
|
|
42
|
+
* `"inherit"` to forward streams to the parent process.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const child = invokeLocusStream(["run", "42"]);
|
|
47
|
+
* child.stdout?.on("data", (chunk) => process.stdout.write(chunk));
|
|
48
|
+
* child.on("exit", (code) => console.log("exited with", code));
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param args - Arguments to pass after `locus`, e.g. `["run", "42"]`.
|
|
52
|
+
* @param cwd - Working directory for the child process. Defaults to
|
|
53
|
+
* `process.cwd()`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function invokeLocusStream(args: string[], cwd?: string): ChildProcess;
|
|
56
|
+
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../src/invoke.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,iBAAiB,CAAC,CAe5B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,YAAY,CAO5E"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple structured logger for community package authors.
|
|
3
|
+
*
|
|
4
|
+
* Produces output that is visually consistent with the Locus CLI's own
|
|
5
|
+
* terminal output (same prefix symbols and colour coding). All output goes
|
|
6
|
+
* to `process.stderr` so it does not pollute `stdout` that packages may use
|
|
7
|
+
* for machine-readable data.
|
|
8
|
+
*/
|
|
9
|
+
/** Logger instance returned by {@link createLogger}. */
|
|
10
|
+
export interface LocusLogger {
|
|
11
|
+
/**
|
|
12
|
+
* Log an informational message.
|
|
13
|
+
* Displayed with a `●` prefix in cyan.
|
|
14
|
+
*/
|
|
15
|
+
info(msg: string, data?: Record<string, unknown>): void;
|
|
16
|
+
/**
|
|
17
|
+
* Log a warning message.
|
|
18
|
+
* Displayed with a `⚠` prefix in yellow.
|
|
19
|
+
*/
|
|
20
|
+
warn(msg: string, data?: Record<string, unknown>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Log an error message.
|
|
23
|
+
* Displayed with a `✗` prefix in red.
|
|
24
|
+
*/
|
|
25
|
+
error(msg: string, data?: Record<string, unknown>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Log a debug message.
|
|
28
|
+
* Only visible when the `LOCUS_DEBUG` environment variable is set.
|
|
29
|
+
*/
|
|
30
|
+
debug(msg: string, data?: Record<string, unknown>): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a named logger instance whose output style matches the Locus CLI.
|
|
34
|
+
*
|
|
35
|
+
* The `name` is displayed as a prefix so users can identify which package
|
|
36
|
+
* produced a given log line, e.g. `[telegram] Starting bot...`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { createLogger } from "@locusai/sdk";
|
|
41
|
+
*
|
|
42
|
+
* const logger = createLogger("telegram");
|
|
43
|
+
* logger.info("Bot started");
|
|
44
|
+
* logger.error("Connection failed", { code: 503 });
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param name - Short identifier for the package, shown in every log line.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createLogger(name: string): LocusLogger;
|
|
50
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqBH,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD;;;OAGG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzD;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC1D;AASD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CA6BtD"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the `"locus"` metadata field inside a community package's
|
|
3
|
+
* `package.json`. Packages must include this field to be fully recognised and
|
|
4
|
+
* listed by the Locus CLI.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```json
|
|
8
|
+
* {
|
|
9
|
+
* "name": "locus-telegram",
|
|
10
|
+
* "locus": {
|
|
11
|
+
* "displayName": "Telegram",
|
|
12
|
+
* "description": "Remote-control Locus via Telegram",
|
|
13
|
+
* "commands": ["telegram"],
|
|
14
|
+
* "version": "1.0.0"
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface LocusPackageManifest {
|
|
20
|
+
/** Human-readable name shown in `locus packages list` and the marketplace. */
|
|
21
|
+
displayName: string;
|
|
22
|
+
/** One-line description of what the package does. */
|
|
23
|
+
description: string;
|
|
24
|
+
/** Sub-commands contributed by this package, e.g. `["telegram"]`. */
|
|
25
|
+
commands: string[];
|
|
26
|
+
/** Semver version string — should mirror the npm package version. */
|
|
27
|
+
version: string;
|
|
28
|
+
}
|
|
29
|
+
/** Supported AI provider identifiers. */
|
|
30
|
+
export type AIProvider = "claude" | "codex";
|
|
31
|
+
/** Shape of the project-level `.locus/config.json`. */
|
|
32
|
+
export interface LocusConfig {
|
|
33
|
+
/** Config schema version, e.g. `"0.19.1"`. */
|
|
34
|
+
version: string;
|
|
35
|
+
/** GitHub repository settings. */
|
|
36
|
+
github: {
|
|
37
|
+
/** Repository owner (user or org). */
|
|
38
|
+
owner: string;
|
|
39
|
+
/** Repository name. */
|
|
40
|
+
repo: string;
|
|
41
|
+
/** Default branch, usually `"main"`. */
|
|
42
|
+
defaultBranch: string;
|
|
43
|
+
};
|
|
44
|
+
/** AI provider and model settings. */
|
|
45
|
+
ai: {
|
|
46
|
+
/** Active provider. */
|
|
47
|
+
provider: AIProvider;
|
|
48
|
+
/** Model ID, e.g. `"claude-sonnet-4-6"`. */
|
|
49
|
+
model: string;
|
|
50
|
+
};
|
|
51
|
+
/** Agent execution settings. */
|
|
52
|
+
agent: {
|
|
53
|
+
/** Maximum number of parallel agent tasks. */
|
|
54
|
+
maxParallel: number;
|
|
55
|
+
/** Whether to auto-apply labels on issues. */
|
|
56
|
+
autoLabel: boolean;
|
|
57
|
+
/** Whether to auto-create PRs after task completion. */
|
|
58
|
+
autoPR: boolean;
|
|
59
|
+
/** Base branch for agent branches. */
|
|
60
|
+
baseBranch: string;
|
|
61
|
+
/** Whether to rebase from base branch before each task. */
|
|
62
|
+
rebaseBeforeTask: boolean;
|
|
63
|
+
};
|
|
64
|
+
/** Sprint settings. */
|
|
65
|
+
sprint: {
|
|
66
|
+
/** Active sprint label, or `null` if none. */
|
|
67
|
+
active: string | null;
|
|
68
|
+
/** Whether to stop the sprint on the first failure. */
|
|
69
|
+
stopOnFailure: boolean;
|
|
70
|
+
};
|
|
71
|
+
/** Logging settings. */
|
|
72
|
+
logging: {
|
|
73
|
+
/** Log verbosity level. */
|
|
74
|
+
level: "silent" | "normal" | "verbose" | "debug";
|
|
75
|
+
/** Maximum number of log files to keep. */
|
|
76
|
+
maxFiles: number;
|
|
77
|
+
/** Maximum total log size in MB before pruning. */
|
|
78
|
+
maxTotalSizeMB: number;
|
|
79
|
+
};
|
|
80
|
+
/** Sandbox execution settings. */
|
|
81
|
+
sandbox?: {
|
|
82
|
+
/** Whether sandboxed execution is enabled. */
|
|
83
|
+
enabled: boolean;
|
|
84
|
+
/** User-managed persistent sandbox names per provider. */
|
|
85
|
+
providers: Record<string, string | undefined>;
|
|
86
|
+
/** Additional workspace paths to mount. */
|
|
87
|
+
extraWorkspaces: string[];
|
|
88
|
+
/** Paths to mount as read-only. */
|
|
89
|
+
readOnlyPaths: string[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Community package configuration.
|
|
93
|
+
* Each key is the package name (e.g. `"telegram"`), and the value is an
|
|
94
|
+
* arbitrary config object owned by that package.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```json
|
|
98
|
+
* {
|
|
99
|
+
* "packages": {
|
|
100
|
+
* "telegram": {
|
|
101
|
+
* "botToken": "123456:ABC...",
|
|
102
|
+
* "chatIds": [12345678]
|
|
103
|
+
* }
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
packages?: Record<string, Record<string, unknown>>;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,yCAAyC;AACzC,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE5C,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,MAAM,EAAE;QACN,sCAAsC;QACtC,KAAK,EAAE,MAAM,CAAC;QACd,uBAAuB;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,wCAAwC;QACxC,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,sCAAsC;IACtC,EAAE,EAAE;QACF,uBAAuB;QACvB,QAAQ,EAAE,UAAU,CAAC;QACrB,4CAA4C;QAC5C,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,gCAAgC;IAChC,KAAK,EAAE;QACL,8CAA8C;QAC9C,WAAW,EAAE,MAAM,CAAC;QACpB,8CAA8C;QAC9C,SAAS,EAAE,OAAO,CAAC;QACnB,wDAAwD;QACxD,MAAM,EAAE,OAAO,CAAC;QAChB,sCAAsC;QACtC,UAAU,EAAE,MAAM,CAAC;QACnB,2DAA2D;QAC3D,gBAAgB,EAAE,OAAO,CAAC;KAC3B,CAAC;IACF,uBAAuB;IACvB,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,uDAAuD;QACvD,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;IACF,wBAAwB;IACxB,OAAO,EAAE;QACP,2BAA2B;QAC3B,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;QACjD,2CAA2C;QAC3C,QAAQ,EAAE,MAAM,CAAC;QACjB,mDAAmD;QACnD,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,kCAAkC;IAClC,OAAO,CAAC,EAAE;QACR,8CAA8C;QAC9C,OAAO,EAAE,OAAO,CAAC;QACjB,0DAA0D;QAC1D,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;QAC9C,2CAA2C;QAC3C,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,mCAAmC;QACnC,aAAa,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IACF;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD"}
|