@codeworksh/harness 0.6.0-dev.20261102163121 → 0.6.0-dev.20261103153032

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/effect.d.mts CHANGED
@@ -28302,24 +28302,38 @@ type Provides = io_d_exports.SandboxIO.Provides;
28302
28302
  /** A sandbox is any Layer providing the runtime services above. */
28303
28303
  type Sandbox<E = never, RIn = never> = Layer.Layer<Provides, E, RIn>;
28304
28304
  declare namespace git_d_exports {
28305
- export { AppProcessError, git_d_exports as Git, Interface$16 as Interface, Result$1 as Result, RevParse, Service$16 as Service, defaultLayer$5 as defaultLayer, layer$16 as layer, layerWith$5 as layerWith, resolvePath };
28305
+ export { CloneInput, CommandError, git_d_exports as Git, Interface$16 as Interface, OperationError, Result$1 as Result, RevParse, Service$16 as Service, defaultLayer$5 as defaultLayer, layer$16 as layer, layerWith$5 as layerWith, resolvePath };
28306
28306
  }
28307
- declare const AppProcessError_base: Schema.Class<AppProcessError, Schema.TaggedStruct<"AppProcessError", {
28308
- readonly command: Schema.String;
28309
- readonly exitCode: Schema.optional<Schema.Finite>;
28310
- readonly stderr: Schema.optional<Schema.String>;
28307
+ declare const CommandError_base: Schema.Class<CommandError, Schema.TaggedStruct<"Git.CommandError", {
28308
+ readonly args: Schema.$Array<Schema.String>;
28311
28309
  readonly cause: Schema.optional<Schema.Defect>;
28312
28310
  }>, import("effect/Cause").YieldableError>;
28313
- declare class AppProcessError extends AppProcessError_base {}
28311
+ /** Git could not be run at all: the process failed to spawn. */
28312
+ declare class CommandError extends CommandError_base {}
28313
+ declare const OperationError_base: Schema.Class<OperationError, Schema.TaggedStruct<"Git.OperationError", {
28314
+ readonly operation: Schema.Literals<readonly ["init", "clone", "fetch", "checkout", "reset", "push"]>;
28315
+ readonly message: Schema.String;
28316
+ readonly directory: Schema.optional<Schema.String>;
28317
+ readonly cause: Schema.optional<Schema.Defect>;
28318
+ }>, import("effect/Cause").YieldableError>;
28319
+ /** A git operation that ran and failed; `message` is git's own stderr when it printed one. */
28320
+ declare class OperationError extends OperationError_base {}
28314
28321
  interface Result$1 {
28315
28322
  readonly exitCode: number;
28316
28323
  readonly text: string;
28317
28324
  readonly stderr: string;
28318
28325
  }
28326
+ interface CloneInput {
28327
+ readonly remote: string;
28328
+ readonly target: string;
28329
+ readonly branch?: string;
28330
+ readonly depth?: number;
28331
+ readonly env?: Record<string, string>;
28332
+ }
28319
28333
  type RevParse = "--show-toplevel" | "--git-dir" | "--git-common-dir";
28320
28334
  interface Interface$16 {
28321
28335
  /** Run `git <args>` in `directory`; fails only when the process cannot be spawned. */
28322
- readonly exec: (directory: string, args: ReadonlyArray<string>) => Effect.Effect<Result$1, AppProcessError>;
28336
+ readonly exec: (directory: string, args: ReadonlyArray<string>) => Effect.Effect<Result$1, CommandError>;
28323
28337
  readonly revParse: (directory: string, arg: RevParse) => Effect.Effect<string | undefined>;
28324
28338
  readonly remote: (directory: string, name?: string) => Effect.Effect<string | undefined>;
28325
28339
  readonly roots: (directory: string) => Effect.Effect<string[]>;
@@ -28328,22 +28342,22 @@ interface Interface$16 {
28328
28342
  readonly dir: (directory: string) => Effect.Effect<string | undefined>;
28329
28343
  readonly branch: (directory: string) => Effect.Effect<string | undefined>;
28330
28344
  readonly remoteHead: (directory: string) => Effect.Effect<string | undefined>;
28331
- readonly clone: (input: {
28332
- remote: string;
28333
- target: string;
28334
- branch?: string;
28335
- depth?: number;
28336
- }) => Effect.Effect<Result$1, AppProcessError>;
28337
- readonly fetch: (directory: string) => Effect.Effect<Result$1, AppProcessError>;
28338
- readonly fetchBranch: (directory: string, branch: string) => Effect.Effect<Result$1, AppProcessError>;
28339
- readonly checkout: (directory: string, branch: string) => Effect.Effect<Result$1, AppProcessError>;
28340
- readonly reset: (directory: string, target: string) => Effect.Effect<Result$1, AppProcessError>;
28345
+ /** A new repository in `directory`, which must exist; `branch` names its first branch. */
28346
+ readonly init: (directory: string, options?: {
28347
+ readonly branch?: string;
28348
+ }) => Effect.Effect<void, OperationError>;
28349
+ /** A full clone unless `depth` asks for a shallow one; `target` must not exist yet. */
28350
+ readonly clone: (input: CloneInput) => Effect.Effect<void, OperationError>;
28351
+ readonly fetch: (directory: string) => Effect.Effect<void, OperationError>;
28352
+ readonly fetchBranch: (directory: string, branch: string) => Effect.Effect<void, OperationError>;
28353
+ readonly checkout: (directory: string, branch: string) => Effect.Effect<void, OperationError>;
28354
+ readonly reset: (directory: string, target: string) => Effect.Effect<void, OperationError>;
28341
28355
  readonly push: (input: {
28342
28356
  readonly directory: string;
28343
28357
  readonly refspec: string;
28344
28358
  readonly remote?: string;
28345
28359
  readonly env?: Record<string, string>;
28346
- }) => Effect.Effect<Result$1, AppProcessError>;
28360
+ }) => Effect.Effect<void, OperationError>;
28347
28361
  }
28348
28362
  declare const Service_base$14: Context.ServiceClass<Service$16, "@codeworksh/harness/git/git/Service", Interface$16>;
28349
28363
  declare class Service$16 extends Service_base$14 {}
@@ -32041,6 +32055,18 @@ declare const login: (input: {
32041
32055
  /** Remove the server's stored credentials. Returns whether there were any. */
32042
32056
  declare const signOut: (store: Store, server: Pick<Server, "name" | "url">) => Effect.Effect<boolean, OAuthError, never>;
32043
32057
  //#endregion
32058
+ //#region src/util/home.d.ts
32059
+ /**
32060
+ * Expand a leading `~`, leaving every other value untouched for the caller to resolve.
32061
+ *
32062
+ * The path module is the caller's, because the home directory is host-native while some
32063
+ * callers spell their paths POSIX-only. Anything beyond the tilde is not this function's
32064
+ * business: it never resolves, normalizes, or validates.
32065
+ */
32066
+ export declare const expandTilde: (value: string, path: {
32067
+ readonly join: (...parts: ReadonlyArray<string>) => string;
32068
+ }) => string;
32069
+ //#endregion
32044
32070
  //#region src/plugin/host.d.ts
32045
32071
  declare const SetupError_base: Schema.Class<SetupError, Schema.TaggedStruct<"Plugin.SetupError", {
32046
32072
  readonly pluginId: Schema.optional<Schema.String>;
@@ -32274,5 +32300,5 @@ type DateTimeUtcFromMillis = import__codeworksh_plugin_schema.DateTimeUtcFromMil
32274
32300
  type EventSchema = import__codeworksh_plugin_event.EventSchema;
32275
32301
  type SandboxError = import__codeworksh_plugin_sandbox_errors.SandboxError;
32276
32302
  type optional = import__codeworksh_plugin_schema.optional;
32277
- export { control_d_exports as Control, db_d_exports as Database, DateTimeUtcFromMillis, schema_d_exports as DocumentSchema, event_d_exports as Event, list_d_exports as EventList, registry_d_exports as EventRegistry, EventSchema, global_d_exports as Global, harness_d_exports as Harness, location_d_exports as Location, mcp_d_exports as Mcp, config_d_exports as McpConfig, error_d_exports as McpError, oauth_d_exports as McpOAuth, catalog_d_exports as ModelCatalog, index_d_exports as Plugin, project_d_exports as Project, schema_d_exports$1 as PromptSchema, run_d_exports as Runner, sandbox_d_exports as Sandbox, SandboxError, session_d_exports as Session, session_d_exports$1 as SessionStore, settings_d_exports as Settings, state_d_exports as State, schema_d_exports$2 as ThreadSchema, thread_d_exports as ThreadStore, tool_d_exports as Tool, optional };
32303
+ export { control_d_exports as Control, db_d_exports as Database, DateTimeUtcFromMillis, schema_d_exports as DocumentSchema, event_d_exports as Event, list_d_exports as EventList, registry_d_exports as EventRegistry, EventSchema, git_d_exports as Git, global_d_exports as Global, harness_d_exports as Harness, location_d_exports as Location, mcp_d_exports as Mcp, config_d_exports as McpConfig, error_d_exports as McpError, oauth_d_exports as McpOAuth, catalog_d_exports as ModelCatalog, index_d_exports as Plugin, project_d_exports as Project, schema_d_exports$1 as PromptSchema, run_d_exports as Runner, sandbox_d_exports as Sandbox, SandboxError, session_d_exports as Session, session_d_exports$1 as SessionStore, settings_d_exports as Settings, state_d_exports as State, schema_d_exports$2 as ThreadSchema, thread_d_exports as ThreadStore, tool_d_exports as Tool, optional };
32278
32304
  //# sourceMappingURL=effect.d.mts.map
package/effect.mjs CHANGED
@@ -3463,10 +3463,10 @@ var global_exports = /* @__PURE__ */ __exportAll({
3463
3463
  app: () => app,
3464
3464
  appConfigDir: () => appConfigDir,
3465
3465
  authFile: () => authFile,
3466
- defaultLayer: () => defaultLayer$3,
3466
+ defaultLayer: () => defaultLayer$4,
3467
3467
  homeConfig: () => homeConfig,
3468
3468
  layer: () => layer$27,
3469
- layerWith: () => layerWith$1,
3469
+ layerWith: () => layerWith$2,
3470
3470
  make: () => make$21,
3471
3471
  resolve: () => resolve$5
3472
3472
  });
@@ -3513,8 +3513,8 @@ const build = (input) => Effect.gen(function* () {
3513
3513
  return Service$17.of(paths);
3514
3514
  });
3515
3515
  const layer$27 = Layer.effect(Service$17, build({}));
3516
- const defaultLayer$3 = layer$27;
3517
- const layerWith$1 = (input) => Layer.effect(Service$17, build(input));
3516
+ const defaultLayer$4 = layer$27;
3517
+ const layerWith$2 = (input) => Layer.effect(Service$17, build(input));
3518
3518
  //#endregion
3519
3519
  //#region src/util/jsonc.ts
3520
3520
  /** `line:column`, 1-based, for a parser offset into the source. */
@@ -5809,7 +5809,7 @@ var db_exports = /* @__PURE__ */ __exportAll({
5809
5809
  Database: () => db_exports,
5810
5810
  SqlClient: () => SqlClient$1,
5811
5811
  SqlSchema: () => SqlSchema$1,
5812
- defaultLayer: () => defaultLayer$2,
5812
+ defaultLayer: () => defaultLayer$3,
5813
5813
  layer: () => layer$26,
5814
5814
  locationConfig: () => locationConfig,
5815
5815
  path: () => path$1,
@@ -5843,7 +5843,7 @@ const path$1 = Effect.fn("Database.path")(function* (data) {
5843
5843
  const directory = data ?? (yield* resolve$5()).data;
5844
5844
  return resolveDatabaseLocation(yield* locationConfig, directory);
5845
5845
  });
5846
- const defaultLayer$2 = Layer.unwrap(path$1().pipe(Effect.map(layer$26)));
5846
+ const defaultLayer$3 = Layer.unwrap(path$1().pipe(Effect.map(layer$26)));
5847
5847
  //#endregion
5848
5848
  //#region src/space/space.ts
5849
5849
  /** `hash(env, location)` — no project component (D-SPACEID). */
@@ -7606,13 +7606,36 @@ const make$9 = () => {
7606
7606
  */
7607
7607
  const services = (backend, identity) => Layer.provideMerge(io_exports.SandboxIO.mount(identity), Layer.provideMerge(Layer.merge(layer$24, layer$21()), backend));
7608
7608
  /** Default sandbox: the real OS filesystem and processes, mounted at `cwd`. */
7609
- const defaultLayer$1 = (cwd) => services(layer$23(), io_exports.SandboxIO.host(cwd));
7609
+ const defaultLayer$2 = (cwd) => services(layer$23(), io_exports.SandboxIO.host(cwd));
7610
7610
  //#endregion
7611
7611
  //#region src/git/git.ts
7612
- var AppProcessError = class extends Schema.TaggedError()("AppProcessError", {
7613
- command: Schema.String,
7614
- exitCode: Schema.optional(Schema.Finite),
7615
- stderr: Schema.optional(Schema.String),
7612
+ var git_exports = /* @__PURE__ */ __exportAll({
7613
+ CommandError: () => CommandError,
7614
+ Git: () => git_exports,
7615
+ OperationError: () => OperationError,
7616
+ Service: () => Service$15,
7617
+ defaultLayer: () => defaultLayer$1,
7618
+ layer: () => layer$18,
7619
+ layerWith: () => layerWith$1,
7620
+ resolvePath: () => resolvePath
7621
+ });
7622
+ /** Git could not be run at all: the process failed to spawn. */
7623
+ var CommandError = class extends Schema.TaggedError()("Git.CommandError", {
7624
+ args: Schema.Array(Schema.String),
7625
+ cause: Schema.optional(Schema.Defect())
7626
+ }) {};
7627
+ /** A git operation that ran and failed; `message` is git's own stderr when it printed one. */
7628
+ var OperationError = class extends Schema.TaggedError()("Git.OperationError", {
7629
+ operation: Schema.Literals([
7630
+ "init",
7631
+ "clone",
7632
+ "fetch",
7633
+ "checkout",
7634
+ "reset",
7635
+ "push"
7636
+ ]),
7637
+ message: Schema.String,
7638
+ directory: Schema.optional(Schema.String),
7616
7639
  cause: Schema.optional(Schema.Defect())
7617
7640
  }) {};
7618
7641
  var Service$15 = class extends Context.Service()("@codeworksh/harness/git/git/Service") {};
@@ -7625,8 +7648,8 @@ const layer$18 = Layer.effect(Service$15, Effect.gen(function* () {
7625
7648
  exitCode: result.exitCode,
7626
7649
  text: result.stdout,
7627
7650
  stderr: result.stderr
7628
- })), Effect.mapError((cause) => new AppProcessError({
7629
- command: ["git", ...args].join(" "),
7651
+ })), Effect.mapError((cause) => new CommandError({
7652
+ args: [...args],
7630
7653
  cause
7631
7654
  })));
7632
7655
  const run = (cwd) => (args) => execute(cwd)(args).pipe(Effect.orElseSucceed(() => ({
@@ -7691,37 +7714,47 @@ const layer$18 = Layer.effect(Service$15, Effect.gen(function* () {
7691
7714
  if (result.exitCode !== 0) return void 0;
7692
7715
  return result.text.trim().replace(/^refs\/remotes\//, "") || void 0;
7693
7716
  });
7694
- const clone = Effect.fn("Git.clone")((input) => execute(posix.dirname(input.target))([
7717
+ const operation = (name, directory, args, options) => execute(directory)(args, options).pipe(Effect.mapError((cause) => new OperationError({
7718
+ operation: name,
7719
+ directory,
7720
+ message: `Could not run git ${name}`,
7721
+ cause
7722
+ })), Effect.flatMap((result) => result.exitCode === 0 ? Effect.void : Effect.fail(new OperationError({
7723
+ operation: name,
7724
+ directory,
7725
+ message: result.stderr.trim() || result.text.trim() || `git ${name} failed`
7726
+ }))));
7727
+ const init = Effect.fn("Git.init")((directory, options) => operation("init", directory, ["init", ...options?.branch ? [`--initial-branch=${options.branch}`] : []]));
7728
+ const clone = Effect.fn("Git.clone")((input) => operation("clone", posix.dirname(input.target), [
7695
7729
  "clone",
7696
- "--depth",
7697
- String(input.depth ?? 100),
7730
+ ...input.depth === void 0 ? [] : ["--depth", String(input.depth)],
7698
7731
  ...input.branch ? ["--branch", input.branch] : [],
7699
7732
  "--",
7700
7733
  input.remote,
7701
7734
  input.target
7702
- ]));
7703
- const fetch = Effect.fn("Git.fetch")((directory) => execute(directory)([
7735
+ ], input.env === void 0 ? void 0 : { env: input.env }));
7736
+ const fetch = Effect.fn("Git.fetch")((directory) => operation("fetch", directory, [
7704
7737
  "fetch",
7705
7738
  "--all",
7706
7739
  "--prune"
7707
7740
  ]));
7708
- const fetchBranch = Effect.fn("Git.fetchBranch")((directory, branch) => execute(directory)([
7741
+ const fetchBranch = Effect.fn("Git.fetchBranch")((directory, branch) => operation("fetch", directory, [
7709
7742
  "fetch",
7710
7743
  "origin",
7711
7744
  `+refs/heads/${branch}:refs/remotes/origin/${branch}`
7712
7745
  ]));
7713
- const checkout = Effect.fn("Git.checkout")((directory, branch) => execute(directory)([
7746
+ const checkout = Effect.fn("Git.checkout")((directory, branch) => operation("checkout", directory, [
7714
7747
  "checkout",
7715
7748
  "-B",
7716
7749
  branch,
7717
7750
  `origin/${branch}`
7718
7751
  ]));
7719
- const reset = Effect.fn("Git.reset")((directory, target) => execute(directory)([
7752
+ const reset = Effect.fn("Git.reset")((directory, target) => operation("reset", directory, [
7720
7753
  "reset",
7721
7754
  "--hard",
7722
7755
  target
7723
7756
  ]));
7724
- const push = Effect.fn("Git.push")((input) => execute(input.directory)([
7757
+ const push = Effect.fn("Git.push")((input) => operation("push", input.directory, [
7725
7758
  "push",
7726
7759
  "--",
7727
7760
  input.remote ?? "origin",
@@ -7737,6 +7770,7 @@ const layer$18 = Layer.effect(Service$15, Effect.gen(function* () {
7737
7770
  dir,
7738
7771
  branch,
7739
7772
  remoteHead,
7773
+ init,
7740
7774
  clone,
7741
7775
  fetch,
7742
7776
  fetchBranch,
@@ -7745,6 +7779,17 @@ const layer$18 = Layer.effect(Service$15, Effect.gen(function* () {
7745
7779
  push
7746
7780
  });
7747
7781
  }));
7782
+ /**
7783
+ * Run git inside the given sandbox — local, remote, or virtual. Every command
7784
+ * goes through the sandbox shell, so git never executes anywhere other than
7785
+ * where the caller's files live. Discovery and identity live in `repo/`,
7786
+ * worktree management in `worktree/`; this module is only the command runner.
7787
+ *
7788
+ * The sandbox must have a real `git` binary. A VFS-backed shell (`EnvBash`) has
7789
+ * builtins only, so commands there exit 127 and every probe reports nothing.
7790
+ */
7791
+ const layerWith$1 = (sandbox) => layer$18.pipe(Layer.provide(sandbox));
7792
+ const defaultLayer$1 = (rootPath) => layerWith$1(defaultLayer$2(rootPath));
7748
7793
  /** Resolve a (possibly relative) git output path against `cwd`, trimming the trailing newline. */
7749
7794
  function resolvePath(cwd, value) {
7750
7795
  const trimmed = value.replace(/[\r\n]+$/, "");
@@ -8119,8 +8164,8 @@ const rename = Effect.fn("Project.rename")(function* (input) {
8119
8164
  });
8120
8165
  });
8121
8166
  /** Takes an assembled sandbox — local or remote — not a local backend. */
8122
- const layerWith = (sandbox) => layer$15.pipe(Layer.provide(Layer.mergeAll(layer$17, layer$16, layer$25)), Layer.provide(layer$18), Layer.provide(sandbox), Layer.provide(defaultLayer$2));
8123
- const defaultLayer = (path) => layerWith(defaultLayer$1(path));
8167
+ const layerWith = (sandbox) => layer$15.pipe(Layer.provide(Layer.mergeAll(layer$17, layer$16, layer$25)), Layer.provide(layer$18), Layer.provide(sandbox), Layer.provide(defaultLayer$3));
8168
+ const defaultLayer = (path) => layerWith(defaultLayer$2(path));
8124
8169
  //#endregion
8125
8170
  //#region src/location/location.ts
8126
8171
  var location_exports = /* @__PURE__ */ __exportAll({
@@ -16265,7 +16310,7 @@ var harness_exports = /* @__PURE__ */ __exportAll({
16265
16310
  const layer = (options = {}) => Layer.unwrap(Effect.gen(function* () {
16266
16311
  const hostCwd = options.hostCwd ?? process.cwd();
16267
16312
  const paths = yield* resolve$5(options.home === void 0 ? {} : { home: hostPath.resolve(hostCwd, expandTilde(options.home, hostPath)) });
16268
- const global = layerWith$1(paths);
16313
+ const global = layerWith$2(paths);
16269
16314
  const settingsOptions = options.userConfigDir === void 0 ? {} : { userConfigDir: userConfigDir(options.userConfigDir, hostCwd) };
16270
16315
  const config = yield* load$3({
16271
16316
  ...settingsOptions,
@@ -16804,6 +16849,6 @@ var DateTimeUtcFromMillis = schema_exports$9.DateTimeUtcFromMillis;
16804
16849
  var EventSchema = schema_exports$11.EventSchema;
16805
16850
  var SandboxError = errors_exports.SandboxError;
16806
16851
  var optional = schema_exports$9.optional;
16807
- export { control_exports as Control, db_exports as Database, DateTimeUtcFromMillis, schema_exports as DocumentSchema, event_exports as Event, list_exports as EventList, registry_exports as EventRegistry, EventSchema, global_exports as Global, harness_exports as Harness, location_exports as Location, mcp_exports as Mcp, config_exports as McpConfig, error_exports as McpError, oauth_exports as McpOAuth, catalog_exports as ModelCatalog, plugin_exports as Plugin, project_exports as Project, schema_exports$1 as PromptSchema, run_exports as Runner, sandbox_exports as Sandbox, SandboxError, session_exports as Session, session_exports$1 as SessionStore, settings_exports as Settings, state_exports as State, schema_exports$2 as ThreadSchema, thread_exports as ThreadStore, tool_exports as Tool, optional };
16852
+ export { control_exports as Control, db_exports as Database, DateTimeUtcFromMillis, schema_exports as DocumentSchema, event_exports as Event, list_exports as EventList, registry_exports as EventRegistry, EventSchema, git_exports as Git, global_exports as Global, harness_exports as Harness, location_exports as Location, mcp_exports as Mcp, config_exports as McpConfig, error_exports as McpError, oauth_exports as McpOAuth, catalog_exports as ModelCatalog, plugin_exports as Plugin, project_exports as Project, schema_exports$1 as PromptSchema, run_exports as Runner, sandbox_exports as Sandbox, SandboxError, session_exports as Session, session_exports$1 as SessionStore, settings_exports as Settings, state_exports as State, schema_exports$2 as ThreadSchema, thread_exports as ThreadStore, tool_exports as Tool, expandTilde, optional };
16808
16853
 
16809
16854
  //# sourceMappingURL=effect.mjs.map