@kovari/code 0.0.0-stage → 0.1.0
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/API.md +3 -0
- package/ARCHITECTURE.md +3 -0
- package/LICENSE +5 -0
- package/README.md +45 -2
- package/SECURITY.md +3 -0
- package/assets/icon-128.png +0 -0
- package/assets/icon.png +0 -0
- package/dist/command.d.ts +24 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +21 -0
- package/dist/command.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +3 -0
- package/dist/core.js.map +1 -0
- package/dist/diagnostics.d.ts +18 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +9 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/edit.d.ts +28 -0
- package/dist/edit.d.ts.map +1 -0
- package/dist/edit.js +24 -0
- package/dist/edit.js.map +1 -0
- package/dist/events.d.ts +3 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +3 -0
- package/dist/events.js.map +1 -0
- package/dist/git.d.ts +12 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +17 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.d.ts +3 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +3 -0
- package/dist/logging.js.map +1 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +3 -0
- package/dist/runtime.js.map +1 -0
- package/dist/sdk.d.ts +21 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +10 -0
- package/dist/sdk.js.map +1 -0
- package/dist/search.d.ts +18 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +22 -0
- package/dist/search.js.map +1 -0
- package/dist/security.d.ts +3 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +3 -0
- package/dist/security.js.map +1 -0
- package/dist/testing.d.ts +20 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +10 -0
- package/dist/testing.js.map +1 -0
- package/dist/workspace.d.ts +9 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +4 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +168 -4
package/API.md
ADDED
package/ARCHITECTURE.md
ADDED
package/LICENSE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center"><img src="./assets/icon.png" width="180" height="180" alt="@kovari/code logo"><h1>@kovari/code</h1><p><strong>Advanced repository intelligence and controlled coding effects powered by Kovari.</strong></p></div>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Overview
|
|
4
|
+
`@kovari/code` builds coding-agent capabilities on the published `kovari` runtime. Shared configuration, events, retries, concurrency, policies, logging, workspaces and testing utilities are imported from `kovari@0.1.1`; this package adds command execution, transactional edits, repository search, Git operations, diagnostics and a composed coding SDK.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
```bash
|
|
8
|
+
npm install @kovari/code
|
|
9
|
+
```
|
|
10
|
+
The normal dependency installs `kovari@^0.1.1` automatically.
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
```ts
|
|
14
|
+
import createKovariCode from "@kovari/code";
|
|
15
|
+
import { FakeModelProvider } from "@kovari/code/testing";
|
|
16
|
+
const code = createKovariCode({ model: new FakeModelProvider("Ready"), config: { workspaceRoot: process.cwd() } });
|
|
17
|
+
console.log(await code.search.text("TODO", { extensions: [".ts"], limit: 25 }));
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Kovari integration
|
|
21
|
+
- `core`, `config`, `events`, `runtime`, `security` and `logging` re-export Kovari contracts.
|
|
22
|
+
- Workspace behaviour extends the secure Kovari workspace boundary.
|
|
23
|
+
- Commands use Kovari policies and events.
|
|
24
|
+
- Search uses Kovari concurrency controls.
|
|
25
|
+
- The SDK composes the Kovari agent runtime with coding capabilities.
|
|
26
|
+
|
|
27
|
+
## Quality gates
|
|
28
|
+
```bash
|
|
29
|
+
npm install
|
|
30
|
+
npm ci
|
|
31
|
+
npm run typecheck
|
|
32
|
+
npm run build
|
|
33
|
+
npm test
|
|
34
|
+
npm run validate
|
|
35
|
+
npm run check
|
|
36
|
+
npm run pack:verify
|
|
37
|
+
npm run pack:dry
|
|
38
|
+
npm run publish:dry
|
|
39
|
+
npm run release:check
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Security
|
|
43
|
+
Paths stay inside the configured workspace root. Process execution uses explicit argument arrays with no shell. Policies authorise effects, cancellation limits work, and edit transactions write temporary files before replacement.
|
|
44
|
+
|
|
45
|
+
## Licence
|
|
46
|
+
MIT.
|
package/SECURITY.md
ADDED
|
Binary file
|
package/assets/icon.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PolicyEngine } from "kovari/security";
|
|
2
|
+
import { EventBus } from "kovari/events";
|
|
3
|
+
export interface CommandRequest {
|
|
4
|
+
command: string;
|
|
5
|
+
args?: readonly string[];
|
|
6
|
+
cwd?: string;
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
env?: Readonly<Record<string, string>>;
|
|
10
|
+
}
|
|
11
|
+
export interface CommandResult {
|
|
12
|
+
exitCode: number | null;
|
|
13
|
+
stdout: string;
|
|
14
|
+
stderr: string;
|
|
15
|
+
durationMs: number;
|
|
16
|
+
ok: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class CommandExecutor {
|
|
19
|
+
readonly policy: PolicyEngine;
|
|
20
|
+
readonly events: EventBus;
|
|
21
|
+
constructor(policy?: PolicyEngine, events?: EventBus);
|
|
22
|
+
run(r: CommandRequest): Promise<CommandResult>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAsC,OAAM,EAAC,YAAY,EAAC,MAAI,iBAAiB,CAAC;AAAA,OAAM,EAAC,QAAQ,EAAC,MAAI,eAAe,CAAC;AAAA,MAAM,WAAW,cAAc;IAAC,OAAO,EAAC,MAAM,CAAC;IAAA,IAAI,CAAC,EAAC,SAAS,MAAM,EAAE,CAAC;IAAA,GAAG,CAAC,EAAC,MAAM,CAAC;IAAA,SAAS,CAAC,EAAC,MAAM,CAAC;IAAA,MAAM,CAAC,EAAC,WAAW,CAAC;IAAA,GAAG,CAAC,EAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAC,MAAM,CAAC,CAAC,CAAA;CAAC;AAAA,MAAM,WAAW,aAAa;IAAC,QAAQ,EAAC,MAAM,GAAC,IAAI,CAAC;IAAA,MAAM,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAC;IAAA,UAAU,EAAC,MAAM,CAAC;IAAA,EAAE,EAAC,OAAO,CAAA;CAAC;AAAA,qBAAa,eAAe;IAAa,QAAQ,CAAC,MAAM;IAAoB,QAAQ,CAAC,MAAM;gBAAzC,MAAM,eAAmB,EAAU,MAAM,WAAe;IAAS,GAAG,CAAC,CAAC,EAAC,cAAc,GAAE,OAAO,CAAC,aAAa,CAAC;CAAs6B"}
|
package/dist/command.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { PolicyEngine } from "kovari/security";
|
|
3
|
+
import { EventBus } from "kovari/events";
|
|
4
|
+
export class CommandExecutor {
|
|
5
|
+
policy;
|
|
6
|
+
events;
|
|
7
|
+
constructor(policy = new PolicyEngine(), events = new EventBus()) {
|
|
8
|
+
this.policy = policy;
|
|
9
|
+
this.events = events;
|
|
10
|
+
}
|
|
11
|
+
async run(r) { await this.policy.authorize({ effect: "process", resource: r.command }); const runId = crypto.randomUUID(), started = Date.now(); await this.events.emit("code.command.started", { command: r.command, args: r.args ?? [] }, runId); const signal = r.signal ? AbortSignal.any([r.signal, AbortSignal.timeout(r.timeoutMs ?? 120000)]) : AbortSignal.timeout(r.timeoutMs ?? 120000); try {
|
|
12
|
+
const result = await new Promise((resolve, reject) => { const c = spawn(r.command, [...(r.args ?? [])], { cwd: r.cwd, shell: false, windowsHide: true, signal, env: r.env ? { ...process.env, ...r.env } : process.env }); let stdout = "", stderr = ""; c.stdout?.on("data", x => stdout += x); c.stderr?.on("data", x => stderr += x); c.once("error", reject); c.once("close", exitCode => resolve({ exitCode, stdout, stderr, durationMs: Date.now() - started, ok: exitCode === 0 })); });
|
|
13
|
+
await this.events.emit("code.command.completed", result, runId);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
await this.events.emit("code.command.failed", { error }, runId);
|
|
18
|
+
throw error;
|
|
19
|
+
} }
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"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"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,eAAe,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,eAAe,CAAC"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,aAAa,CAAC"}
|
package/dist/core.js
ADDED
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface Diagnostic {
|
|
2
|
+
source: string;
|
|
3
|
+
severity: "error" | "warning";
|
|
4
|
+
message: string;
|
|
5
|
+
file?: string;
|
|
6
|
+
line?: number;
|
|
7
|
+
column?: number;
|
|
8
|
+
code?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseTypeScriptDiagnostics(text: string): Diagnostic[];
|
|
11
|
+
export declare class DiagnosticCollection {
|
|
12
|
+
#private;
|
|
13
|
+
add(...items: Diagnostic[]): this;
|
|
14
|
+
all(): readonly Diagnostic[];
|
|
15
|
+
errors(): Diagnostic[];
|
|
16
|
+
clear(): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IAAC,MAAM,EAAC,MAAM,CAAC;IAAA,QAAQ,EAAC,OAAO,GAAC,SAAS,CAAC;IAAA,OAAO,EAAC,MAAM,CAAC;IAAA,IAAI,CAAC,EAAC,MAAM,CAAC;IAAA,IAAI,CAAC,EAAC,MAAM,CAAC;IAAA,MAAM,CAAC,EAAC,MAAM,CAAC;IAAA,IAAI,CAAC,EAAC,MAAM,CAAA;CAAC;AAAA,wBAAgB,0BAA0B,CAAC,IAAI,EAAC,MAAM,GAAE,UAAU,EAAE,CAAoS;AAAA,qBAAa,oBAAoB;;IAAwB,GAAG,CAAC,GAAG,KAAK,EAAC,UAAU,EAAE;IAAyC,GAAG;IAA0C,MAAM;IAAsD,KAAK;CAAmB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function parseTypeScriptDiagnostics(text) { return text.split(/\r?\n/).flatMap(row => { const m = /^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/.exec(row); return m?.[1] && m[2] && m[3] && m[4] && m[5] && m[6] ? [{ source: "typescript", file: m[1], line: Number(m[2]), column: Number(m[3]), severity: m[4], code: m[5], message: m[6] }] : []; }); }
|
|
2
|
+
export class DiagnosticCollection {
|
|
3
|
+
#items = [];
|
|
4
|
+
add(...items) { this.#items.push(...items); return this; }
|
|
5
|
+
all() { return Object.freeze([...this.#items]); }
|
|
6
|
+
errors() { return this.#items.filter(x => x.severity === "error"); }
|
|
7
|
+
clear() { this.#items = []; }
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAA0I,MAAM,UAAU,0BAA0B,CAAC,IAAW,IAAe,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,CAAA,EAAE,GAAC,MAAM,CAAC,GAAC,sDAAsD,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAE,CAAC,CAAC,CAAC,CAAC,IAAE,CAAC,CAAC,CAAC,CAAC,IAAE,CAAC,CAAC,CAAC,CAAC,IAAE,CAAC,CAAC,CAAC,CAAC,IAAE,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAA,CAAC,EAAC,MAAM,EAAC,YAAY,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,IAAI,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,MAAM,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,CAAC,CAAoB,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAA,CAAC,CAAA,EAAE,CAAA,CAAA,CAAC,CAAC,CAAA,CAAA,CAAC;AAAA,MAAM,OAAO,oBAAoB;IAAC,MAAM,GAAc,EAAE,CAAC;IAAA,GAAG,CAAC,GAAG,KAAkB,IAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAA,OAAO,IAAI,CAAA,CAAA,CAAC;IAAA,GAAG,KAAG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA,CAAA,CAAC;IAAA,MAAM,KAAG,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,CAAC,QAAQ,KAAG,OAAO,CAAC,CAAA,CAAA,CAAC;IAAA,KAAK,KAAG,IAAI,CAAC,MAAM,GAAC,EAAE,CAAA,CAAA,CAAC;CAAC"}
|
package/dist/edit.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Workspace } from "kovari/workspace";
|
|
2
|
+
import { PolicyEngine } from "kovari/security";
|
|
3
|
+
export interface PlannedEdit {
|
|
4
|
+
path: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class EditTransaction {
|
|
8
|
+
#private;
|
|
9
|
+
private workspace;
|
|
10
|
+
private policy;
|
|
11
|
+
constructor(workspace: Workspace, policy?: PolicyEngine);
|
|
12
|
+
write(path: string, content: string): this;
|
|
13
|
+
preview(): Readonly<{
|
|
14
|
+
operations: Readonly<{
|
|
15
|
+
path: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}>[];
|
|
18
|
+
paths: readonly string[];
|
|
19
|
+
}>;
|
|
20
|
+
commit(): Promise<Readonly<{
|
|
21
|
+
operations: Readonly<{
|
|
22
|
+
path: string;
|
|
23
|
+
content: string;
|
|
24
|
+
}>[];
|
|
25
|
+
paths: readonly string[];
|
|
26
|
+
}>>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAwH,OAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAAA,OAAM,EAAC,YAAY,EAAC,MAAI,iBAAiB,CAAC;AAAA,MAAM,WAAW,WAAW;IAAC,IAAI,EAAC,MAAM,CAAC;IAAA,OAAO,EAAC,MAAM,CAAA;CAAC;AAAA,qBAAa,eAAe;;IAAmC,OAAO,CAAC,SAAS;IAAW,OAAO,CAAC,MAAM;gBAAlC,SAAS,EAAC,SAAS,EAAS,MAAM,eAAmB;IAAG,KAAK,CAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,MAAM;IAAuE,OAAO;;kBAAnQ,MAAM;qBAAS,MAAM;;;;IAA8X,MAAM;;kBAAzZ,MAAM;qBAAS,MAAM;;;;CAAurB"}
|
package/dist/edit.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mkdir, rename, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { Workspace } from "kovari/workspace";
|
|
5
|
+
import { PolicyEngine } from "kovari/security";
|
|
6
|
+
export class EditTransaction {
|
|
7
|
+
workspace;
|
|
8
|
+
policy;
|
|
9
|
+
#ops = [];
|
|
10
|
+
constructor(workspace, policy = new PolicyEngine()) {
|
|
11
|
+
this.workspace = workspace;
|
|
12
|
+
this.policy = policy;
|
|
13
|
+
}
|
|
14
|
+
write(path, content) { this.workspace.path(path); this.#ops.push({ path, content }); return this; }
|
|
15
|
+
preview() { return Object.freeze({ operations: this.#ops.map(x => Object.freeze({ ...x })), paths: Object.freeze([...new Set(this.#ops.map(x => x.path))]) }); }
|
|
16
|
+
async commit() { for (const op of this.#ops) {
|
|
17
|
+
await this.policy.authorize({ effect: "write", resource: op.path });
|
|
18
|
+
const target = this.workspace.path(op.path), temp = `${target}.${randomUUID()}.tmp`;
|
|
19
|
+
await mkdir(dirname(target), { recursive: true });
|
|
20
|
+
await writeFile(temp, op.content, "utf8");
|
|
21
|
+
await rename(temp, target);
|
|
22
|
+
} return this.preview(); }
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=edit.js.map
|
package/dist/edit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,KAAK,EAAC,MAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAAA,OAAM,EAAC,OAAO,EAAC,MAAI,WAAW,CAAC;AAAA,OAAM,EAAC,UAAU,EAAC,MAAI,aAAa,CAAC;AAAA,OAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAAA,OAAM,EAAC,YAAY,EAAC,MAAI,iBAAiB,CAAC;AAAwD,MAAM,OAAO,eAAe;IAA2C;IAA4B;IAAtE,IAAI,GAAe,EAAE,CAAC;IAAA,YAAoB,SAAmB,EAAS,SAAO,IAAI,YAAY,EAAE;QAArD,cAAS,GAAT,SAAS,CAAU;QAAS,WAAM,GAAN,MAAM,CAAmB;IAAE,CAAC;IAAA,KAAK,CAAC,IAAW,EAAC,OAAc,IAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC,CAAA,OAAO,IAAI,CAAA,CAAA,CAAC;IAAA,OAAO,KAAG,OAAO,MAAM,CAAC,MAAM,CAAC,EAAC,UAAU,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,EAAE,CAAA,MAAM,CAAC,MAAM,CAAC,EAAC,GAAG,CAAC,EAAC,CAAC,CAAC,EAAC,KAAK,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAA,CAAA,CAAC;IAAA,KAAK,CAAC,MAAM,KAAG,KAAI,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,EAAC,CAAC;QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,OAAO,EAAC,QAAQ,EAAC,EAAE,CAAC,IAAI,EAAC,CAAC,CAAC;QAAA,MAAM,MAAM,GAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAC,IAAI,GAAC,GAAG,MAAM,IAAI,UAAU,EAAE,MAAM,CAAC;QAAA,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAC,EAAC,SAAS,EAAC,IAAI,EAAC,CAAC,CAAC;QAAA,MAAM,SAAS,CAAC,IAAI,EAAC,EAAE,CAAC,OAAO,EAAC,MAAM,CAAC,CAAC;QAAA,MAAM,MAAM,CAAC,IAAI,EAAC,MAAM,CAAC,CAAA;IAAA,CAAC,CAAA,OAAO,IAAI,CAAC,OAAO,EAAE,CAAA,CAAA,CAAC;CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,eAAe,CAAC"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,eAAe,CAAC"}
|
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommandExecutor } from "./command.js";
|
|
2
|
+
export declare class GitRepository {
|
|
3
|
+
readonly root: string;
|
|
4
|
+
private commands;
|
|
5
|
+
constructor(root: string, commands?: CommandExecutor);
|
|
6
|
+
private git;
|
|
7
|
+
status(): Promise<string>;
|
|
8
|
+
diff(staged?: boolean): Promise<string>;
|
|
9
|
+
log(limit?: number): Promise<string>;
|
|
10
|
+
show(ref?: string): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,eAAe,EAAC,MAAI,cAAc,CAAC;AAAA,qBAAa,aAAa;IAAa,QAAQ,CAAC,IAAI,EAAC,MAAM;IAAC,OAAO,CAAC,QAAQ;gBAA5B,IAAI,EAAC,MAAM,EAAS,QAAQ,kBAAsB;YAAiB,GAAG;IAAsK,MAAM;IAA2D,IAAI,CAAC,MAAM,UAAM;IAAwE,GAAG,CAAC,KAAK,SAAG;IAA4I,IAAI,CAAC,GAAG,SAAO;CAAsD"}
|
package/dist/git.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommandExecutor } from "./command.js";
|
|
2
|
+
export class GitRepository {
|
|
3
|
+
root;
|
|
4
|
+
commands;
|
|
5
|
+
constructor(root, commands = new CommandExecutor()) {
|
|
6
|
+
this.root = root;
|
|
7
|
+
this.commands = commands;
|
|
8
|
+
}
|
|
9
|
+
async git(args) { const r = await this.commands.run({ command: "git", args, cwd: this.root }); if (!r.ok)
|
|
10
|
+
throw Error(r.stderr || `git exited ${r.exitCode}`); return r.stdout.trim(); }
|
|
11
|
+
status() { return this.git(["status", "--porcelain=v1", "--branch"]); }
|
|
12
|
+
diff(staged = false) { return this.git(["diff", ...(staged ? ["--cached"] : []), "--no-ext-diff"]); }
|
|
13
|
+
log(limit = 20) { if (!Number.isInteger(limit) || limit < 1 || limit > 500)
|
|
14
|
+
throw RangeError("limit"); return this.git(["log", `-${limit}`, "--format=%H%x09%aI%x09%s"]); }
|
|
15
|
+
show(ref = "HEAD") { return this.git(["show", "--stat", "--oneline", ref]); }
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,eAAe,EAAC,MAAI,cAAc,CAAC;AAAA,MAAM,OAAO,aAAa;IAAsB;IAAoB;IAAzC,YAAqB,IAAW,EAAS,WAAS,IAAI,eAAe,EAAE;QAAlD,SAAI,GAAJ,IAAI,CAAO;QAAS,aAAQ,GAAR,QAAQ,CAAsB;IAAE,CAAC;IAAQ,KAAK,CAAC,GAAG,CAAC,IAAa,IAAE,MAAM,CAAC,GAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAC,OAAO,EAAC,KAAK,EAAC,IAAI,EAAC,GAAG,EAAC,IAAI,CAAC,IAAI,EAAC,CAAC,CAAC,CAAA,IAAG,CAAC,CAAC,CAAC,EAAE;QAAC,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM,IAAE,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA,CAAA,CAAC;IAAA,MAAM,KAAG,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAC,gBAAgB,EAAC,UAAU,CAAC,CAAC,CAAA,CAAA,CAAC;IAAA,IAAI,CAAC,MAAM,GAAC,KAAK,IAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAC,GAAG,CAAC,MAAM,CAAA,CAAC,CAAA,CAAC,UAAU,CAAC,CAAA,CAAC,CAAA,EAAE,CAAC,EAAC,eAAe,CAAC,CAAC,CAAA,CAAA,CAAC;IAAA,GAAG,CAAC,KAAK,GAAC,EAAE,IAAE,IAAG,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAE,KAAK,GAAC,CAAC,IAAE,KAAK,GAAC,GAAG;QAAC,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAC,IAAI,KAAK,EAAE,EAAC,0BAA0B,CAAC,CAAC,CAAA,CAAA,CAAC;IAAA,IAAI,CAAC,GAAG,GAAC,MAAM,IAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAC,QAAQ,EAAC,WAAW,EAAC,GAAG,CAAC,CAAC,CAAA,CAAA,CAAC;CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default, createKovariCode } from "./sdk.js";
|
|
2
|
+
export * from "./command.js";
|
|
3
|
+
export * from "./edit.js";
|
|
4
|
+
export * from "./search.js";
|
|
5
|
+
export * from "./git.js";
|
|
6
|
+
export * from "./diagnostics.js";
|
|
7
|
+
export * from "./testing.js";
|
|
8
|
+
export * from "./workspace.js";
|
|
9
|
+
export * from "kovari";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,OAAO,EAAC,gBAAgB,EAAC,MAAI,UAAU,CAAC;AAAA,cAAW,cAAc,CAAC;AAAA,cAAW,WAAW,CAAC;AAAA,cAAW,aAAa,CAAC;AAAA,cAAW,UAAU,CAAC;AAAA,cAAW,kBAAkB,CAAC;AAAA,cAAW,cAAc,CAAC;AAAA,cAAW,gBAAgB,CAAC;AAAA,cAAW,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default, createKovariCode } from "./sdk.js";
|
|
2
|
+
export * from "./command.js";
|
|
3
|
+
export * from "./edit.js";
|
|
4
|
+
export * from "./search.js";
|
|
5
|
+
export * from "./git.js";
|
|
6
|
+
export * from "./diagnostics.js";
|
|
7
|
+
export * from "./testing.js";
|
|
8
|
+
export * from "./workspace.js";
|
|
9
|
+
export * from "kovari";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,OAAO,EAAC,gBAAgB,EAAC,MAAI,UAAU,CAAC;AAAA,cAAW,cAAc,CAAC;AAAA,cAAW,WAAW,CAAC;AAAA,cAAW,aAAa,CAAC;AAAA,cAAW,UAAU,CAAC;AAAA,cAAW,kBAAkB,CAAC;AAAA,cAAW,cAAc,CAAC;AAAA,cAAW,gBAAgB,CAAC;AAAA,cAAW,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,gBAAgB,CAAC"}
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,gBAAgB,CAAC"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,gBAAgB,CAAC"}
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Config } from "kovari/config";
|
|
2
|
+
import { Workspace } from "kovari/workspace";
|
|
3
|
+
import type { ModelProvider } from "kovari/models";
|
|
4
|
+
import { CommandExecutor } from "./command.js";
|
|
5
|
+
import { EditTransaction } from "./edit.js";
|
|
6
|
+
import { GitRepository } from "./git.js";
|
|
7
|
+
import { RepositorySearch } from "./search.js";
|
|
8
|
+
export declare function createKovariCode(o: {
|
|
9
|
+
model: ModelProvider;
|
|
10
|
+
config?: Partial<Config>;
|
|
11
|
+
}): Readonly<{
|
|
12
|
+
kovari: any;
|
|
13
|
+
config: Readonly<Config>;
|
|
14
|
+
workspace: Workspace;
|
|
15
|
+
commands: CommandExecutor;
|
|
16
|
+
git: GitRepository;
|
|
17
|
+
search: RepositorySearch;
|
|
18
|
+
edit: () => EditTransaction;
|
|
19
|
+
}>;
|
|
20
|
+
export default createKovariCode;
|
|
21
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAiC,OAAM,EAAc,KAAK,MAAM,EAAC,MAAI,eAAe,CAAC;AAAA,OAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAAA,OAAO,KAAI,EAAC,aAAa,EAAC,MAAI,eAAe,CAAC;AAAA,OAAM,EAAC,eAAe,EAAC,MAAI,cAAc,CAAC;AAAA,OAAM,EAAC,eAAe,EAAC,MAAI,WAAW,CAAC;AAAA,OAAM,EAAC,aAAa,EAAC,MAAI,UAAU,CAAC;AAAA,OAAM,EAAC,gBAAgB,EAAC,MAAI,aAAa,CAAC;AAAA,wBAAgB,gBAAgB,CAAC,CAAC,EAAC;IAAC,KAAK,EAAC,aAAa,CAAC;IAAA,MAAM,CAAC,EAAC,OAAO,CAAC,MAAM,CAAC,CAAA;CAAC;;;;;;;;GAA6Y;AAAA,eAAe,gBAAgB,CAAC"}
|
package/dist/sdk.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createKovari } from "kovari";
|
|
2
|
+
import { defineConfig } from "kovari/config";
|
|
3
|
+
import { Workspace } from "kovari/workspace";
|
|
4
|
+
import { CommandExecutor } from "./command.js";
|
|
5
|
+
import { EditTransaction } from "./edit.js";
|
|
6
|
+
import { GitRepository } from "./git.js";
|
|
7
|
+
import { RepositorySearch } from "./search.js";
|
|
8
|
+
export function createKovariCode(o) { const config = defineConfig(o.config), kovari = createKovari({ model: o.model, config }), workspace = new Workspace(config.workspaceRoot, config.limits.maxBytes), commands = new CommandExecutor(); return Object.freeze({ kovari, config, workspace, commands, git: new GitRepository(config.workspaceRoot, commands), search: new RepositorySearch(workspace, config.limits.concurrency), edit: () => new EditTransaction(workspace) }); }
|
|
9
|
+
export default createKovariCode;
|
|
10
|
+
//# sourceMappingURL=sdk.js.map
|
package/dist/sdk.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,YAAY,EAAC,MAAI,QAAQ,CAAC;AAAA,OAAM,EAAC,YAAY,EAAa,MAAI,eAAe,CAAC;AAAA,OAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAA8C,OAAM,EAAC,eAAe,EAAC,MAAI,cAAc,CAAC;AAAA,OAAM,EAAC,eAAe,EAAC,MAAI,WAAW,CAAC;AAAA,OAAM,EAAC,aAAa,EAAC,MAAI,UAAU,CAAC;AAAA,OAAM,EAAC,gBAAgB,EAAC,MAAI,aAAa,CAAC;AAAA,MAAM,UAAU,gBAAgB,CAAC,CAA+C,IAAE,MAAM,MAAM,GAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,EAAC,MAAM,GAAC,YAAY,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC,KAAK,EAAC,MAAM,EAAC,CAAC,EAAC,SAAS,GAAC,IAAI,SAAS,CAAC,MAAM,CAAC,aAAa,EAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAC,QAAQ,GAAC,IAAI,eAAe,EAAE,CAAC,CAAA,OAAO,MAAM,CAAC,MAAM,CAAC,EAAC,MAAM,EAAC,MAAM,EAAC,SAAS,EAAC,QAAQ,EAAC,GAAG,EAAC,IAAI,aAAa,CAAC,MAAM,CAAC,aAAa,EAAC,QAAQ,CAAC,EAAC,MAAM,EAAC,IAAI,gBAAgB,CAAC,SAAS,EAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAC,IAAI,EAAC,GAAE,EAAE,CAAA,IAAI,eAAe,CAAC,SAAS,CAAC,EAAC,CAAC,CAAA,CAAA,CAAC;AAAA,eAAe,gBAAgB,CAAC"}
|
package/dist/search.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Workspace } from "kovari/workspace";
|
|
2
|
+
export interface SearchMatch {
|
|
3
|
+
path: string;
|
|
4
|
+
line: number;
|
|
5
|
+
column: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class RepositorySearch {
|
|
9
|
+
private workspace;
|
|
10
|
+
private concurrency;
|
|
11
|
+
constructor(workspace: Workspace, concurrency?: number);
|
|
12
|
+
text(query: string, o?: {
|
|
13
|
+
caseSensitive?: boolean;
|
|
14
|
+
limit?: number;
|
|
15
|
+
extensions?: readonly string[];
|
|
16
|
+
}): Promise<SearchMatch[]>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAAsC,MAAM,WAAW,WAAW;IAAC,IAAI,EAAC,MAAM,CAAC;IAAA,IAAI,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAC;IAAA,IAAI,EAAC,MAAM,CAAA;CAAC;AAAA,qBAAa,gBAAgB;IAAa,OAAO,CAAC,SAAS;IAAW,OAAO,CAAC,WAAW;gBAAvC,SAAS,EAAC,SAAS,EAAS,WAAW,SAAE;IAAS,IAAI,CAAC,KAAK,EAAC,MAAM,EAAC,CAAC,GAAC;QAAC,aAAa,CAAC,EAAC,OAAO,CAAC;QAAA,KAAK,CAAC,EAAC,MAAM,CAAC;QAAA,UAAU,CAAC,EAAC,SAAS,MAAM,EAAE,CAAA;KAAI,GAAE,OAAO,CAAC,WAAW,EAAE,CAAC;CAAopB"}
|
package/dist/search.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Workspace } from "kovari/workspace";
|
|
2
|
+
import { Semaphore } from "kovari/runtime";
|
|
3
|
+
export class RepositorySearch {
|
|
4
|
+
workspace;
|
|
5
|
+
concurrency;
|
|
6
|
+
constructor(workspace, concurrency = 4) {
|
|
7
|
+
this.workspace = workspace;
|
|
8
|
+
this.concurrency = concurrency;
|
|
9
|
+
}
|
|
10
|
+
async text(query, o = {}) { const needle = o.caseSensitive ? query : query.toLowerCase(), limit = o.limit ?? 200, out = [], sem = new Semaphore(this.concurrency); await Promise.all((await this.workspace.files()).map(path => sem.run(async () => { if (out.length >= limit || o.extensions?.length && !o.extensions.some(e => path.endsWith(e)))
|
|
11
|
+
return; let text = ""; try {
|
|
12
|
+
text = await this.workspace.read(path);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return;
|
|
16
|
+
} for (const [i, line] of text.split(/\r?\n/).entries()) {
|
|
17
|
+
const column = (o.caseSensitive ? line : line.toLowerCase()).indexOf(needle);
|
|
18
|
+
if (column >= 0 && out.length < limit)
|
|
19
|
+
out.push({ path, line: i + 1, column: column + 1, text: line });
|
|
20
|
+
} }))); return out.sort((a, b) => a.path.localeCompare(b.path) || a.line - b.line).slice(0, limit); }
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAAA,OAAM,EAAC,SAAS,EAAC,MAAI,gBAAgB,CAAC;AAA+E,MAAM,OAAO,gBAAgB;IAAqB;IAA4B;IAAhD,YAAoB,SAAmB,EAAS,cAAY,CAAC;QAAzC,cAAS,GAAT,SAAS,CAAU;QAAS,gBAAW,GAAX,WAAW,CAAE;IAAE,CAAC;IAAA,KAAK,CAAC,IAAI,CAAC,KAAY,EAAC,IAAuE,EAAE,IAAyB,MAAM,MAAM,GAAC,CAAC,CAAC,aAAa,CAAA,CAAC,CAAA,KAAK,CAAA,CAAC,CAAA,KAAK,CAAC,WAAW,EAAE,EAAC,KAAK,GAAC,CAAC,CAAC,KAAK,IAAE,GAAG,EAAC,GAAG,GAAe,EAAE,EAAC,GAAG,GAAC,IAAI,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAA,EAAE,CAAA,GAAG,CAAC,GAAG,CAAC,KAAK,IAAE,EAAE,GAAC,IAAG,GAAG,CAAC,MAAM,IAAE,KAAK,IAAE,CAAC,CAAC,UAAU,EAAE,MAAM,IAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA,EAAE,CAAA,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAAC,OAAO,CAAA,IAAI,IAAI,GAAC,EAAE,CAAC,CAAA,IAAG,CAAC;QAAA,IAAI,GAAC,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAAA,CAAC;IAAA,MAAK,CAAC;QAAA,OAAM;IAAA,CAAC,CAAA,KAAI,MAAK,CAAC,CAAC,EAAC,IAAI,CAAC,IAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAC,CAAC;QAAA,MAAM,MAAM,GAAC,CAAC,CAAC,CAAC,aAAa,CAAA,CAAC,CAAA,IAAI,CAAA,CAAC,CAAA,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAAA,IAAG,MAAM,IAAE,CAAC,IAAE,GAAG,CAAC,MAAM,GAAC,KAAK;YAAC,GAAG,CAAC,IAAI,CAAC,EAAC,IAAI,EAAC,IAAI,EAAC,CAAC,GAAC,CAAC,EAAC,MAAM,EAAC,MAAM,GAAC,CAAC,EAAC,IAAI,EAAC,IAAI,EAAC,CAAC,CAAA;IAAA,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAA,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAE,CAAC,CAAC,IAAI,GAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAC,KAAK,CAAC,CAAA,CAAA,CAAC;CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,iBAAiB,CAAC"}
|
package/dist/security.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { FakeModelProvider } from "kovari/testing";
|
|
2
|
+
export declare class FakeCommandExecutor {
|
|
3
|
+
private result;
|
|
4
|
+
readonly calls: unknown[];
|
|
5
|
+
constructor(result?: {
|
|
6
|
+
exitCode: number;
|
|
7
|
+
stdout: string;
|
|
8
|
+
stderr: string;
|
|
9
|
+
durationMs: number;
|
|
10
|
+
ok: boolean;
|
|
11
|
+
});
|
|
12
|
+
run(request: unknown): Promise<{
|
|
13
|
+
exitCode: number;
|
|
14
|
+
stdout: string;
|
|
15
|
+
stderr: string;
|
|
16
|
+
durationMs: number;
|
|
17
|
+
ok: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,iBAAiB,EAAC,MAAI,gBAAgB,CAAC;AAAA,qBAAa,mBAAmB;IAAyC,OAAO,CAAC,MAAM;IAAtD,QAAQ,CAAC,KAAK,EAAC,OAAO,EAAE,CAAI;gBAAoB,MAAM;;;;;;KAAsD;IAAS,GAAG,CAAC,OAAO,EAAC,OAAO;;;;;;;CAAmD"}
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { FakeModelProvider } from "kovari/testing";
|
|
2
|
+
export class FakeCommandExecutor {
|
|
3
|
+
result;
|
|
4
|
+
calls = [];
|
|
5
|
+
constructor(result = { exitCode: 0, stdout: "", stderr: "", durationMs: 0, ok: true }) {
|
|
6
|
+
this.result = result;
|
|
7
|
+
}
|
|
8
|
+
async run(request) { this.calls.push(request); return { ...this.result }; }
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,iBAAiB,EAAC,MAAI,gBAAgB,CAAC;AAAA,MAAM,OAAO,mBAAmB;IAAiD;IAAvC,KAAK,GAAW,EAAE,CAAC;IAAA,YAAoB,SAAO,EAAC,QAAQ,EAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAC,MAAM,EAAC,EAAE,EAAC,UAAU,EAAC,CAAC,EAAC,EAAE,EAAC,IAAI,EAAC;QAA5D,WAAM,GAAN,MAAM,CAAsD;IAAE,CAAC;IAAA,KAAK,CAAC,GAAG,CAAC,OAAe,IAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA,OAAM,EAAC,GAAG,IAAI,CAAC,MAAM,EAAC,CAAA,CAAA,CAAC;CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Workspace as CodeWorkspace } from "kovari/workspace";
|
|
2
|
+
export type WorkspaceSnapshot = {
|
|
3
|
+
root: string;
|
|
4
|
+
files: readonly string[];
|
|
5
|
+
capturedAt: number;
|
|
6
|
+
};
|
|
7
|
+
import { Workspace } from "kovari/workspace";
|
|
8
|
+
export declare function snapshotWorkspace(workspace: Workspace): Promise<WorkspaceSnapshot>;
|
|
9
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,SAAS,IAAI,aAAa,EAAC,MAAI,kBAAkB,CAAC;AAAA,MAAM,MAAM,iBAAiB,GAAC;IAAC,IAAI,EAAC,MAAM,CAAC;IAAA,KAAK,EAAC,SAAS,MAAM,EAAE,CAAC;IAAA,UAAU,EAAC,MAAM,CAAA;CAAC,CAAC;AAAA,OAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAAA,wBAAsB,iBAAiB,CAAC,SAAS,EAAC,SAAS,GAAE,OAAO,CAAC,iBAAiB,CAAC,CAAgH"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Workspace as CodeWorkspace } from "kovari/workspace";
|
|
2
|
+
import { Workspace } from "kovari/workspace";
|
|
3
|
+
export async function snapshotWorkspace(workspace) { return Object.freeze({ root: workspace.root, files: Object.freeze(await workspace.files()), capturedAt: Date.now() }); }
|
|
4
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAM,EAAC,SAAS,IAAI,aAAa,EAAC,MAAI,kBAAkB,CAAC;AAAsF,OAAM,EAAC,SAAS,EAAC,MAAI,kBAAkB,CAAC;AAAA,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAAmB,IAA6B,OAAO,MAAM,CAAC,MAAM,CAAC,EAAC,IAAI,EAAC,SAAS,CAAC,IAAI,EAAC,KAAK,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC,EAAC,UAAU,EAAC,IAAI,CAAC,GAAG,EAAE,EAAC,CAAC,CAAA,CAAA,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,170 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kovari/code",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Advanced repository intelligence and controlled coding effects powered by the Kovari runtime.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"kovari",
|
|
7
|
+
"typescript",
|
|
8
|
+
"developer-tools",
|
|
9
|
+
"coding-agent",
|
|
10
|
+
"repository",
|
|
11
|
+
"ide",
|
|
12
|
+
"git"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/LoonCodeHunter/code#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/LoonCodeHunter/code/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/LoonCodeHunter/code.git"
|
|
21
|
+
},
|
|
22
|
+
"funding": {
|
|
23
|
+
"type": "individual",
|
|
24
|
+
"url": "https://github.com/sponsors/LoonCodeHunter"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"author": {
|
|
28
|
+
"name": "LoonCodeHunter",
|
|
29
|
+
"url": "https://github.com/LoonCodeHunter"
|
|
30
|
+
},
|
|
31
|
+
"type": "module",
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20",
|
|
35
|
+
"npm": ">=10"
|
|
36
|
+
},
|
|
37
|
+
"os": [
|
|
38
|
+
"darwin",
|
|
39
|
+
"linux",
|
|
40
|
+
"win32"
|
|
41
|
+
],
|
|
42
|
+
"packageManager": "npm@10.9.0",
|
|
43
|
+
"main": "./dist/index.js",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
48
|
+
"import": "./dist/index.js",
|
|
49
|
+
"default": "./dist/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./core": {
|
|
52
|
+
"types": "./dist/core.d.ts",
|
|
53
|
+
"import": "./dist/core.js",
|
|
54
|
+
"default": "./dist/core.js"
|
|
55
|
+
},
|
|
56
|
+
"./config": {
|
|
57
|
+
"types": "./dist/config.d.ts",
|
|
58
|
+
"import": "./dist/config.js",
|
|
59
|
+
"default": "./dist/config.js"
|
|
60
|
+
},
|
|
61
|
+
"./events": {
|
|
62
|
+
"types": "./dist/events.d.ts",
|
|
63
|
+
"import": "./dist/events.js",
|
|
64
|
+
"default": "./dist/events.js"
|
|
65
|
+
},
|
|
66
|
+
"./runtime": {
|
|
67
|
+
"types": "./dist/runtime.d.ts",
|
|
68
|
+
"import": "./dist/runtime.js",
|
|
69
|
+
"default": "./dist/runtime.js"
|
|
70
|
+
},
|
|
71
|
+
"./security": {
|
|
72
|
+
"types": "./dist/security.d.ts",
|
|
73
|
+
"import": "./dist/security.js",
|
|
74
|
+
"default": "./dist/security.js"
|
|
75
|
+
},
|
|
76
|
+
"./logging": {
|
|
77
|
+
"types": "./dist/logging.d.ts",
|
|
78
|
+
"import": "./dist/logging.js",
|
|
79
|
+
"default": "./dist/logging.js"
|
|
80
|
+
},
|
|
81
|
+
"./workspace": {
|
|
82
|
+
"types": "./dist/workspace.d.ts",
|
|
83
|
+
"import": "./dist/workspace.js",
|
|
84
|
+
"default": "./dist/workspace.js"
|
|
85
|
+
},
|
|
86
|
+
"./command": {
|
|
87
|
+
"types": "./dist/command.d.ts",
|
|
88
|
+
"import": "./dist/command.js",
|
|
89
|
+
"default": "./dist/command.js"
|
|
90
|
+
},
|
|
91
|
+
"./edit": {
|
|
92
|
+
"types": "./dist/edit.d.ts",
|
|
93
|
+
"import": "./dist/edit.js",
|
|
94
|
+
"default": "./dist/edit.js"
|
|
95
|
+
},
|
|
96
|
+
"./search": {
|
|
97
|
+
"types": "./dist/search.d.ts",
|
|
98
|
+
"import": "./dist/search.js",
|
|
99
|
+
"default": "./dist/search.js"
|
|
100
|
+
},
|
|
101
|
+
"./git": {
|
|
102
|
+
"types": "./dist/git.d.ts",
|
|
103
|
+
"import": "./dist/git.js",
|
|
104
|
+
"default": "./dist/git.js"
|
|
105
|
+
},
|
|
106
|
+
"./diagnostics": {
|
|
107
|
+
"types": "./dist/diagnostics.d.ts",
|
|
108
|
+
"import": "./dist/diagnostics.js",
|
|
109
|
+
"default": "./dist/diagnostics.js"
|
|
110
|
+
},
|
|
111
|
+
"./testing": {
|
|
112
|
+
"types": "./dist/testing.d.ts",
|
|
113
|
+
"import": "./dist/testing.js",
|
|
114
|
+
"default": "./dist/testing.js"
|
|
115
|
+
},
|
|
116
|
+
"./sdk": {
|
|
117
|
+
"types": "./dist/sdk.d.ts",
|
|
118
|
+
"import": "./dist/sdk.js",
|
|
119
|
+
"default": "./dist/sdk.js"
|
|
120
|
+
},
|
|
121
|
+
"./assets/icon.png": "./assets/icon.png",
|
|
122
|
+
"./assets/icon-128.png": "./assets/icon-128.png",
|
|
123
|
+
"./package.json": "./package.json"
|
|
124
|
+
},
|
|
125
|
+
"files": [
|
|
126
|
+
"dist",
|
|
127
|
+
"assets",
|
|
128
|
+
"README.md",
|
|
129
|
+
"API.md",
|
|
130
|
+
"ARCHITECTURE.md",
|
|
131
|
+
"SECURITY.md",
|
|
132
|
+
"LICENSE"
|
|
133
|
+
],
|
|
134
|
+
"scripts": {
|
|
135
|
+
"clean": "node scripts/clean.mjs",
|
|
136
|
+
"typecheck": "node ./node_modules/typescript/bin/tsc -p tsconfig.json --noEmit",
|
|
137
|
+
"build": "npm run clean && node ./node_modules/typescript/bin/tsc -p tsconfig.build.json",
|
|
138
|
+
"test": "node --test tests/*.test.mjs",
|
|
139
|
+
"test:unit": "node --test tests/unit.test.mjs",
|
|
140
|
+
"test:integration": "node --test tests/integration.test.mjs",
|
|
141
|
+
"test:consumer": "node --test tests/consumer.test.mjs",
|
|
142
|
+
"validate:source": "node scripts/validate-source.mjs",
|
|
143
|
+
"validate:package": "node scripts/validate-package.mjs",
|
|
144
|
+
"validate:assets": "node scripts/validate-assets.mjs",
|
|
145
|
+
"validate:exports": "node scripts/validate-exports.mjs",
|
|
146
|
+
"validate:lock": "node scripts/validate-lock.mjs",
|
|
147
|
+
"validate:kovari": "node scripts/validate-kovari.mjs",
|
|
148
|
+
"validate:publish": "node scripts/validate-publish.mjs",
|
|
149
|
+
"validate": "npm run validate:source && npm run validate:package && npm run validate:assets && npm run validate:exports && npm run validate:lock && npm run validate:kovari && npm run validate:publish",
|
|
150
|
+
"check": "npm run compiler:check && npm run typecheck && npm run build && npm test && npm run validate",
|
|
151
|
+
"pack:verify": "node scripts/verify-package.mjs",
|
|
152
|
+
"pack:dry": "npm pack --dry-run --ignore-scripts",
|
|
153
|
+
"publish:dry": "npm publish --dry-run --ignore-scripts --provenance=false",
|
|
154
|
+
"security": "npm audit --audit-level=high",
|
|
155
|
+
"release:check": "npm run check && npm run pack:verify && npm run pack:dry && npm run publish:dry",
|
|
156
|
+
"prepack": "node scripts/prepack.mjs",
|
|
157
|
+
"compiler:check": "node scripts/check-compiler.mjs"
|
|
158
|
+
},
|
|
159
|
+
"publishConfig": {
|
|
160
|
+
"access": "public",
|
|
161
|
+
"registry": "https://registry.npmjs.org/"
|
|
162
|
+
},
|
|
163
|
+
"dependencies": {
|
|
164
|
+
"kovari": "^0.1.1"
|
|
165
|
+
},
|
|
166
|
+
"devDependencies": {
|
|
167
|
+
"@types/node": "22.18.11",
|
|
168
|
+
"typescript": "5.9.3"
|
|
169
|
+
}
|
|
170
|
+
}
|