@h-rig/prompt-plugin 0.0.6-alpha.156

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # @h-rig/prompt-plugin
@@ -0,0 +1,2 @@
1
+ export * from "./plugin";
2
+ export { readPriorPrProgressPromptSection } from "./prompt-context";
@@ -0,0 +1,94 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __returnValue = (v) => v;
4
+ function __exportSetter(name, newValue) {
5
+ this[name] = __returnValue.bind(null, newValue);
6
+ }
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true,
12
+ configurable: true,
13
+ set: __exportSetter.bind(all, name)
14
+ });
15
+ };
16
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
+
18
+ // packages/prompt-plugin/src/prompt-context.ts
19
+ var exports_prompt_context = {};
20
+ __export(exports_prompt_context, {
21
+ readPriorPrProgressPromptSection: () => readPriorPrProgressPromptSection
22
+ });
23
+ import { existsSync, readFileSync } from "fs";
24
+ import { resolve } from "path";
25
+ import { assertPathInsideRoot, safePathSegment } from "@rig/shared/safe-identifiers";
26
+ function readPriorPrProgressPromptSection(projectRoot, taskId) {
27
+ const safeTaskId = safePathSegment(taskId, { fallback: "task", maxLength: 96 });
28
+ const worktreesRoot = resolve(projectRoot, ".worktrees");
29
+ const artifactsRoot = resolve(projectRoot, "artifacts");
30
+ const worktreeArtifactRoot = assertPathInsideRoot(worktreesRoot, resolve(worktreesRoot, safeTaskId, "artifacts", safeTaskId), "prior progress worktree artifact directory");
31
+ const projectArtifactRoot = assertPathInsideRoot(artifactsRoot, resolve(artifactsRoot, safeTaskId), "prior progress artifact directory");
32
+ for (const candidate of [
33
+ resolve(worktreeArtifactRoot, "pr-state.json"),
34
+ resolve(projectArtifactRoot, "pr-state.json")
35
+ ]) {
36
+ if (!existsSync(candidate))
37
+ continue;
38
+ try {
39
+ const raw = JSON.parse(readFileSync(candidate, "utf8"));
40
+ const entries = Array.isArray(raw) ? raw : [raw];
41
+ const first = entries.find((entry) => entry && typeof entry === "object" && typeof entry.url === "string");
42
+ if (!first)
43
+ continue;
44
+ return [
45
+ `Prior progress exists for this task: PR ${first.url}${first.branch ? ` (branch ${first.branch})` : ""} was opened by an earlier run.`,
46
+ "Check its current state first (diff, checks, review). If the work is already complete and checks are green,",
47
+ "run `rig-agent completion-verification` to merge and close instead of re-implementing anything."
48
+ ].join(" ");
49
+ } catch {}
50
+ }
51
+ return null;
52
+ }
53
+ var init_prompt_context = () => {};
54
+
55
+ // packages/prompt-plugin/src/plugin.ts
56
+ import { definePlugin } from "@rig/core/config";
57
+ var PROMPT_PLUGIN_NAME = "@rig/prompt-plugin";
58
+ var PRIOR_PROGRESS_PROMPT_CAPABILITY_ID = "prompt.prior-progress";
59
+ function isPriorProgressPromptInput(input) {
60
+ return typeof input === "object" && input !== null && typeof input.projectRoot === "string" && typeof input.taskId === "string";
61
+ }
62
+ var promptPlugin = definePlugin({
63
+ name: PROMPT_PLUGIN_NAME,
64
+ version: "0.0.0-alpha.1",
65
+ contributes: {
66
+ capabilities: [
67
+ {
68
+ id: PRIOR_PROGRESS_PROMPT_CAPABILITY_ID,
69
+ title: "Prior-progress prompt section",
70
+ description: "Assembles the prior-PR-progress section of a re-dispatched task's prompt.",
71
+ run: async (input) => {
72
+ if (!isPriorProgressPromptInput(input)) {
73
+ throw new Error("prompt.prior-progress input must include string projectRoot and taskId.");
74
+ }
75
+ const { readPriorPrProgressPromptSection: readPriorPrProgressPromptSection2 } = await Promise.resolve().then(() => (init_prompt_context(), exports_prompt_context));
76
+ return readPriorPrProgressPromptSection2(input.projectRoot, input.taskId);
77
+ }
78
+ }
79
+ ]
80
+ }
81
+ });
82
+ function createPromptPlugin() {
83
+ return promptPlugin;
84
+ }
85
+
86
+ // packages/prompt-plugin/src/index.ts
87
+ init_prompt_context();
88
+ export {
89
+ readPriorPrProgressPromptSection,
90
+ promptPlugin,
91
+ createPromptPlugin,
92
+ PROMPT_PLUGIN_NAME,
93
+ PRIOR_PROGRESS_PROMPT_CAPABILITY_ID
94
+ };
@@ -0,0 +1,12 @@
1
+ export declare const PROMPT_PLUGIN_NAME = "@rig/prompt-plugin";
2
+ /** Capability id: agent prompt assembly — the prior-progress section of what
3
+ * the agent is told for a re-dispatched task. Pure input: { projectRoot, taskId }.
4
+ * Output: the prompt section string, or null when there is no prior progress. */
5
+ export declare const PRIOR_PROGRESS_PROMPT_CAPABILITY_ID = "prompt.prior-progress";
6
+ export type PriorProgressPromptInput = {
7
+ readonly projectRoot: string;
8
+ readonly taskId: string;
9
+ };
10
+ export declare const promptPlugin: import("@rig/core/config").RigPlugin;
11
+ export declare function createPromptPlugin(): import("@rig/core/config").RigPlugin;
12
+ export default promptPlugin;
@@ -0,0 +1,92 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __returnValue = (v) => v;
4
+ function __exportSetter(name, newValue) {
5
+ this[name] = __returnValue.bind(null, newValue);
6
+ }
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true,
12
+ configurable: true,
13
+ set: __exportSetter.bind(all, name)
14
+ });
15
+ };
16
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
+
18
+ // packages/prompt-plugin/src/prompt-context.ts
19
+ var exports_prompt_context = {};
20
+ __export(exports_prompt_context, {
21
+ readPriorPrProgressPromptSection: () => readPriorPrProgressPromptSection
22
+ });
23
+ import { existsSync, readFileSync } from "fs";
24
+ import { resolve } from "path";
25
+ import { assertPathInsideRoot, safePathSegment } from "@rig/shared/safe-identifiers";
26
+ function readPriorPrProgressPromptSection(projectRoot, taskId) {
27
+ const safeTaskId = safePathSegment(taskId, { fallback: "task", maxLength: 96 });
28
+ const worktreesRoot = resolve(projectRoot, ".worktrees");
29
+ const artifactsRoot = resolve(projectRoot, "artifacts");
30
+ const worktreeArtifactRoot = assertPathInsideRoot(worktreesRoot, resolve(worktreesRoot, safeTaskId, "artifacts", safeTaskId), "prior progress worktree artifact directory");
31
+ const projectArtifactRoot = assertPathInsideRoot(artifactsRoot, resolve(artifactsRoot, safeTaskId), "prior progress artifact directory");
32
+ for (const candidate of [
33
+ resolve(worktreeArtifactRoot, "pr-state.json"),
34
+ resolve(projectArtifactRoot, "pr-state.json")
35
+ ]) {
36
+ if (!existsSync(candidate))
37
+ continue;
38
+ try {
39
+ const raw = JSON.parse(readFileSync(candidate, "utf8"));
40
+ const entries = Array.isArray(raw) ? raw : [raw];
41
+ const first = entries.find((entry) => entry && typeof entry === "object" && typeof entry.url === "string");
42
+ if (!first)
43
+ continue;
44
+ return [
45
+ `Prior progress exists for this task: PR ${first.url}${first.branch ? ` (branch ${first.branch})` : ""} was opened by an earlier run.`,
46
+ "Check its current state first (diff, checks, review). If the work is already complete and checks are green,",
47
+ "run `rig-agent completion-verification` to merge and close instead of re-implementing anything."
48
+ ].join(" ");
49
+ } catch {}
50
+ }
51
+ return null;
52
+ }
53
+ var init_prompt_context = () => {};
54
+
55
+ // packages/prompt-plugin/src/plugin.ts
56
+ import { definePlugin } from "@rig/core/config";
57
+ var PROMPT_PLUGIN_NAME = "@rig/prompt-plugin";
58
+ var PRIOR_PROGRESS_PROMPT_CAPABILITY_ID = "prompt.prior-progress";
59
+ function isPriorProgressPromptInput(input) {
60
+ return typeof input === "object" && input !== null && typeof input.projectRoot === "string" && typeof input.taskId === "string";
61
+ }
62
+ var promptPlugin = definePlugin({
63
+ name: PROMPT_PLUGIN_NAME,
64
+ version: "0.0.0-alpha.1",
65
+ contributes: {
66
+ capabilities: [
67
+ {
68
+ id: PRIOR_PROGRESS_PROMPT_CAPABILITY_ID,
69
+ title: "Prior-progress prompt section",
70
+ description: "Assembles the prior-PR-progress section of a re-dispatched task's prompt.",
71
+ run: async (input) => {
72
+ if (!isPriorProgressPromptInput(input)) {
73
+ throw new Error("prompt.prior-progress input must include string projectRoot and taskId.");
74
+ }
75
+ const { readPriorPrProgressPromptSection: readPriorPrProgressPromptSection2 } = await Promise.resolve().then(() => (init_prompt_context(), exports_prompt_context));
76
+ return readPriorPrProgressPromptSection2(input.projectRoot, input.taskId);
77
+ }
78
+ }
79
+ ]
80
+ }
81
+ });
82
+ function createPromptPlugin() {
83
+ return promptPlugin;
84
+ }
85
+ var plugin_default = promptPlugin;
86
+ export {
87
+ promptPlugin,
88
+ plugin_default as default,
89
+ createPromptPlugin,
90
+ PROMPT_PLUGIN_NAME,
91
+ PRIOR_PROGRESS_PROMPT_CAPABILITY_ID
92
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Prior-progress context for re-dispatched tasks. Without it a fresh worker
3
+ * re-investigates (or re-implements) finished work from scratch — observed
4
+ * live: a worker spent 25+ minutes rediscovering a green, Greptile-approved
5
+ * PR its predecessor had already opened before an interrupted closeout.
6
+ *
7
+ * Agent prompt assembly is a swappable product domain: this is part of what
8
+ * the agent is told. It lives in @rig/prompt-plugin and is registered as a
9
+ * single-channel capability so the phrasing and the artifact-lookup rules
10
+ * cannot drift apart again across the prompt builders that consume it.
11
+ */
12
+ export declare function readPriorPrProgressPromptSection(projectRoot: string, taskId: string): string | null;
@@ -0,0 +1,35 @@
1
+ // @bun
2
+ // packages/prompt-plugin/src/prompt-context.ts
3
+ import { existsSync, readFileSync } from "fs";
4
+ import { resolve } from "path";
5
+ import { assertPathInsideRoot, safePathSegment } from "@rig/shared/safe-identifiers";
6
+ function readPriorPrProgressPromptSection(projectRoot, taskId) {
7
+ const safeTaskId = safePathSegment(taskId, { fallback: "task", maxLength: 96 });
8
+ const worktreesRoot = resolve(projectRoot, ".worktrees");
9
+ const artifactsRoot = resolve(projectRoot, "artifacts");
10
+ const worktreeArtifactRoot = assertPathInsideRoot(worktreesRoot, resolve(worktreesRoot, safeTaskId, "artifacts", safeTaskId), "prior progress worktree artifact directory");
11
+ const projectArtifactRoot = assertPathInsideRoot(artifactsRoot, resolve(artifactsRoot, safeTaskId), "prior progress artifact directory");
12
+ for (const candidate of [
13
+ resolve(worktreeArtifactRoot, "pr-state.json"),
14
+ resolve(projectArtifactRoot, "pr-state.json")
15
+ ]) {
16
+ if (!existsSync(candidate))
17
+ continue;
18
+ try {
19
+ const raw = JSON.parse(readFileSync(candidate, "utf8"));
20
+ const entries = Array.isArray(raw) ? raw : [raw];
21
+ const first = entries.find((entry) => entry && typeof entry === "object" && typeof entry.url === "string");
22
+ if (!first)
23
+ continue;
24
+ return [
25
+ `Prior progress exists for this task: PR ${first.url}${first.branch ? ` (branch ${first.branch})` : ""} was opened by an earlier run.`,
26
+ "Check its current state first (diff, checks, review). If the work is already complete and checks are green,",
27
+ "run `rig-agent completion-verification` to merge and close instead of re-implementing anything."
28
+ ].join(" ");
29
+ } catch {}
30
+ }
31
+ return null;
32
+ }
33
+ export {
34
+ readPriorPrProgressPromptSection
35
+ };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@h-rig/prompt-plugin",
3
+ "version": "0.0.6-alpha.156",
4
+ "type": "module",
5
+ "description": "First-party agent prompt-assembly capability plugin for Rig.",
6
+ "license": "UNLICENSED",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/src/plugin.d.ts",
14
+ "import": "./dist/src/plugin.js"
15
+ },
16
+ "./plugin": {
17
+ "types": "./dist/src/plugin.d.ts",
18
+ "import": "./dist/src/plugin.js"
19
+ }
20
+ },
21
+ "engines": {
22
+ "bun": ">=1.3.11"
23
+ },
24
+ "main": "./dist/src/index.js",
25
+ "module": "./dist/src/index.js",
26
+ "types": "./dist/src/index.d.ts",
27
+ "dependencies": {
28
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.156",
29
+ "@rig/shared": "npm:@h-rig/shared@0.0.6-alpha.156"
30
+ }
31
+ }