@h-rig/standard-plugin 0.0.6-alpha.8 → 0.0.6-alpha.81

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.
@@ -0,0 +1,18 @@
1
+ import type { RegisteredTaskSource } from "@rig/contracts";
2
+ export interface FilesTaskSourceOptions {
3
+ /**
4
+ * Directory containing one JSON file per task. Use either `path` (matches
5
+ * the `taskSource.path` field in rig.config.ts) or `dir` (back-compat).
6
+ */
7
+ path?: string;
8
+ dir?: string;
9
+ pattern?: RegExp;
10
+ /**
11
+ * Root a relative `path`/`dir` resolves against. The serving process's cwd
12
+ * is NOT the project (workspace-spawned servers run from the engine
13
+ * checkout), so without this a relative path silently reads the WRONG
14
+ * repo's tasks. Defaults to cwd for direct programmatic use.
15
+ */
16
+ projectRoot?: string;
17
+ }
18
+ export declare function createFilesTaskSource(opts: FilesTaskSourceOptions): RegisteredTaskSource;
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // packages/standard-plugin/src/files-source.ts
3
3
  import { readFileSync, readdirSync, existsSync, statSync, writeFileSync } from "fs";
4
- import { join, basename } from "path";
4
+ import { join, basename, isAbsolute, resolve } from "path";
5
5
  var DEFAULT_PATTERN = /\.(task\.)?json$/;
6
6
  function readTaskFile(file, pattern) {
7
7
  const raw = JSON.parse(readFileSync(file, "utf-8"));
@@ -22,10 +22,11 @@ function readTaskFile(file, pattern) {
22
22
  }
23
23
  function createFilesTaskSource(opts) {
24
24
  const pattern = opts.pattern ?? DEFAULT_PATTERN;
25
- const directory = opts.path ?? opts.dir;
26
- if (!directory) {
25
+ const configured = opts.path ?? opts.dir;
26
+ if (!configured) {
27
27
  throw new Error("createFilesTaskSource: either `path` or `dir` must be provided");
28
28
  }
29
+ const directory = isAbsolute(configured) ? configured : resolve(opts.projectRoot ?? process.cwd(), configured);
29
30
  const findTaskFile = (id) => {
30
31
  if (!existsSync(directory))
31
32
  return;
@@ -0,0 +1,67 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import type { RegisteredTaskSource, TaskRecord } from "@rig/contracts";
3
+ export type GitHubCredentialPurpose = "selected-repo" | "admin-fallback";
4
+ export interface GitHubCredentialProvider {
5
+ resolveGitHubToken(input: {
6
+ owner: string;
7
+ repo: string;
8
+ workspaceId: string;
9
+ userId?: string;
10
+ purpose: GitHubCredentialPurpose;
11
+ }): Promise<{
12
+ token: string;
13
+ source: "signed-in-user" | "host-admin-fallback";
14
+ }>;
15
+ }
16
+ export interface GitHubIssuesOptions {
17
+ owner: string;
18
+ repo: string;
19
+ labels?: readonly string[];
20
+ state?: "open" | "closed" | "all";
21
+ assignee?: string;
22
+ ghBinary?: string;
23
+ workspaceId?: string;
24
+ userId?: string;
25
+ credentialProvider?: GitHubCredentialProvider;
26
+ /** Timeout for every gh CLI call. Defaults to 15 seconds. */
27
+ timeoutMs?: number;
28
+ /** Maximum issue-list rows before Rig fails loudly instead of silently truncating. Defaults to 1,000. */
29
+ listLimit?: number;
30
+ /** @internal — for testing. Override the spawnSync used by the adapter. */
31
+ spawn?: typeof spawnSync;
32
+ /** Notify the host that issue-backed task state changed and snapshots should refresh. */
33
+ onTaskChanged?: (event: {
34
+ repo: string;
35
+ id: string;
36
+ status?: string;
37
+ reason: "github-issue-updated";
38
+ }) => void;
39
+ }
40
+ export interface GitHubIssueCreateInput {
41
+ title: string;
42
+ body?: string;
43
+ labels?: readonly string[];
44
+ }
45
+ export interface GitHubIssuesTaskSource extends RegisteredTaskSource {
46
+ addLabels(id: string, labels: readonly string[]): Promise<void>;
47
+ removeLabels(id: string, labels: readonly string[]): Promise<void>;
48
+ createIssue(input: GitHubIssueCreateInput): Promise<TaskRecord>;
49
+ getIssueBody(id: string): Promise<string | undefined>;
50
+ }
51
+ export declare function createEnvGitHubCredentialProvider(): GitHubCredentialProvider;
52
+ export declare function createStateGitHubCredentialProvider(options?: {
53
+ stateFile?: string;
54
+ stateDir?: string;
55
+ }): GitHubCredentialProvider;
56
+ export declare const RIG_STATUS_COMMENT_MARKER = "<!-- rig:status-comment -->";
57
+ export declare const RIG_METADATA_START = "<!-- rig:metadata:start -->";
58
+ export declare const RIG_METADATA_END = "<!-- rig:metadata:end -->";
59
+ export declare function updateRigOwnedMetadataBlock(body: string, metadata: Record<string, unknown>): string;
60
+ export declare function buildRigStickyStatusComment(input: {
61
+ status: "running" | "prOpen" | "ciFixing" | "done" | "needsAttention" | string;
62
+ summary: string;
63
+ runId?: string;
64
+ prUrl?: string;
65
+ details?: readonly string[];
66
+ }): string;
67
+ export declare function createGitHubIssuesTaskSource(opts: GitHubIssuesOptions): GitHubIssuesTaskSource;
@@ -0,0 +1,14 @@
1
+ import { type RigPluginWithRuntime } from "@rig/core";
2
+ import { createEnvGitHubCredentialProvider, createStateGitHubCredentialProvider, createGitHubIssuesTaskSource, type GitHubCredentialProvider, type GitHubIssuesOptions } from "./github-issues-source";
3
+ import { createFilesTaskSource } from "./files-source";
4
+ export { createGitHubIssuesTaskSource, createEnvGitHubCredentialProvider, createStateGitHubCredentialProvider, createFilesTaskSource };
5
+ export type { GitHubIssuesOptions } from "./github-issues-source";
6
+ export type { FilesTaskSourceOptions } from "./files-source";
7
+ export interface StandardPluginOptions {
8
+ githubCredentialProvider?: GitHubCredentialProvider;
9
+ githubWorkspaceId?: string;
10
+ githubUserId?: string;
11
+ githubSpawn?: GitHubIssuesOptions["spawn"];
12
+ onGitHubTaskChanged?: GitHubIssuesOptions["onTaskChanged"];
13
+ }
14
+ export default function standardPlugin(opts?: StandardPluginOptions): RigPluginWithRuntime;
package/dist/src/index.js CHANGED
@@ -476,7 +476,7 @@ function createGitHubIssuesTaskSource(opts) {
476
476
 
477
477
  // packages/standard-plugin/src/files-source.ts
478
478
  import { readFileSync as readFileSync2, readdirSync, existsSync as existsSync2, statSync, writeFileSync } from "fs";
479
- import { join, basename } from "path";
479
+ import { join, basename, isAbsolute, resolve as resolve2 } from "path";
480
480
  var DEFAULT_PATTERN = /\.(task\.)?json$/;
481
481
  function readTaskFile(file, pattern) {
482
482
  const raw = JSON.parse(readFileSync2(file, "utf-8"));
@@ -497,10 +497,11 @@ function readTaskFile(file, pattern) {
497
497
  }
498
498
  function createFilesTaskSource(opts) {
499
499
  const pattern = opts.pattern ?? DEFAULT_PATTERN;
500
- const directory = opts.path ?? opts.dir;
501
- if (!directory) {
500
+ const configured = opts.path ?? opts.dir;
501
+ if (!configured) {
502
502
  throw new Error("createFilesTaskSource: either `path` or `dir` must be provided");
503
503
  }
504
+ const directory = isAbsolute(configured) ? configured : resolve2(opts.projectRoot ?? process.cwd(), configured);
504
505
  const findTaskFile = (id) => {
505
506
  if (!existsSync2(directory))
506
507
  return;
@@ -644,9 +645,10 @@ function standardPlugin(opts = {}) {
644
645
  id: "std:files",
645
646
  kind: "files",
646
647
  description: "JSON files in a local directory",
647
- factory(config) {
648
+ factory(config, context) {
648
649
  return createFilesTaskSource({
649
- path: requireStringField(config, "path", "files")
650
+ path: requireStringField(config, "path", "files"),
651
+ ...context?.projectRoot ? { projectRoot: context.projectRoot } : {}
650
652
  });
651
653
  }
652
654
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/standard-plugin",
3
- "version": "0.0.6-alpha.8",
3
+ "version": "0.0.6-alpha.81",
4
4
  "type": "module",
5
5
  "description": "Rig package",
6
6
  "license": "UNLICENSED",
@@ -10,6 +10,7 @@
10
10
  ],
11
11
  "exports": {
12
12
  ".": {
13
+ "types": "./dist/src/index.d.ts",
13
14
  "import": "./dist/src/index.js"
14
15
  }
15
16
  },
@@ -18,9 +19,10 @@
18
19
  },
19
20
  "main": "./dist/src/index.js",
20
21
  "module": "./dist/src/index.js",
22
+ "types": "./dist/src/index.d.ts",
21
23
  "dependencies": {
22
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.8",
23
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.8",
24
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.81",
25
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.81",
24
26
  "effect": "4.0.0-beta.78"
25
27
  }
26
28
  }