opencode-irf 0.0.10 → 0.0.12-next.1
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 +143 -30
- package/dist/{irf.d.ts → sat.d.ts} +1 -1
- package/dist/sat.d.ts.map +1 -0
- package/dist/sat.js +62 -0
- package/dist/sat.js.map +1 -0
- package/dist/src/append.js +1 -1
- package/dist/src/append.js.map +1 -1
- package/dist/src/format-prompt.d.ts +3 -0
- package/dist/src/format-prompt.d.ts.map +1 -0
- package/dist/src/format-prompt.js +44 -0
- package/dist/src/format-prompt.js.map +1 -0
- package/dist/src/process-prompt.d.ts +19 -0
- package/dist/src/process-prompt.d.ts.map +1 -0
- package/dist/src/process-prompt.js +17 -0
- package/dist/src/process-prompt.js.map +1 -0
- package/dist/src/process.js +1 -1
- package/dist/src/process.js.map +1 -1
- package/dist/src/prompt-prompt.d.ts +3 -0
- package/dist/src/prompt-prompt.d.ts.map +1 -0
- package/dist/src/prompt-prompt.js +47 -0
- package/dist/src/prompt-prompt.js.map +1 -0
- package/dist/src/prompt-schema.d.ts +22 -0
- package/dist/src/prompt-schema.d.ts.map +1 -0
- package/dist/src/prompt-schema.js +33 -0
- package/dist/src/prompt-schema.js.map +1 -0
- package/dist/src/prompt.js +1 -1
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/{schema.d.ts → rule-schema.d.ts} +1 -1
- package/dist/src/rule-schema.d.ts.map +1 -0
- package/dist/src/{schema.js → rule-schema.js} +1 -2
- package/dist/src/rule-schema.js.map +1 -0
- package/dist/src/tools.d.ts +59 -0
- package/dist/src/tools.d.ts.map +1 -0
- package/dist/src/tools.js +205 -0
- package/dist/src/tools.js.map +1 -0
- package/package.json +5 -5
- package/dist/irf.d.ts.map +0 -1
- package/dist/irf.js +0 -183
- package/dist/irf.js.map +0 -1
- package/dist/src/schema.d.ts.map +0 -1
- package/dist/src/schema.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OpenCode SAT - Speech Act Theory
|
|
2
2
|
|
|
3
|
-
An OpenCode plugin that converts unstructured
|
|
3
|
+
An OpenCode plugin that converts unstructured text into structured, consistent formats using speech act theory.
|
|
4
4
|
|
|
5
5
|
<img width="612" height="256" alt="image" src="https://github.com/user-attachments/assets/51edf4b5-831a-4e13-96de-8cad453ea13e" />
|
|
6
6
|
|
|
@@ -9,14 +9,85 @@ An OpenCode plugin that converts unstructured instruction text into structured,
|
|
|
9
9
|
Once installed, just tell OpenCode what you want:
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
|
|
13
|
-
Rewrite instructions.md
|
|
14
|
-
|
|
12
|
+
Rewrite my instruction files
|
|
13
|
+
Rewrite instructions.md in verbose mode
|
|
14
|
+
Add a rule about using early returns
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
Messy or voice-transcribed input is automatically refined into structured tasks before the agent acts on it.
|
|
18
|
+
|
|
19
|
+
## Two Formatters
|
|
20
|
+
|
|
21
|
+
The plugin is built on [speech act theory](https://en.wikipedia.org/wiki/Speech_act) (Austin, Searle). All instructions are **directives**: speech acts that get the hearer to do something. But directives come in two forms, and each needs a different formal framework.
|
|
22
|
+
|
|
23
|
+
### Rule Formatting (deontic logic, regulative directives)
|
|
24
|
+
|
|
25
|
+
Rules constrain ongoing behavior. They are standing obligations, prohibitions, and permissions that persist across all future actions. The formal framework is [deontic logic](https://en.wikipedia.org/wiki/Deontic_logic): what is obligatory, forbidden, and permissible.
|
|
26
|
+
|
|
27
|
+
The plugin parses unstructured rule text into structured components:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
type ParsedRule = {
|
|
31
|
+
strength: 'obligatory' | 'forbidden' | 'permissible' | 'optional' | 'supererogatory' | 'indifferent' | 'omissible'
|
|
32
|
+
action: string
|
|
33
|
+
target: string
|
|
34
|
+
context?: string
|
|
35
|
+
reason: string
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then formats them into one of three output modes: verbose, balanced, or concise.
|
|
40
|
+
|
|
41
|
+
**Status: implemented.** See [Usage](#usage) below.
|
|
42
|
+
|
|
43
|
+
### Prompt Formatting (action/planning logic, performative directives)
|
|
44
|
+
|
|
45
|
+
Prompts request a specific one-shot action. They are not standing rules but immediate instructions. The formal framework is closer to [action languages](https://en.wikipedia.org/wiki/Action_language) from AI planning (STRIPS, ADL, HTN): what the goal is, what must be true before acting, and what changes after.
|
|
46
|
+
|
|
47
|
+
A messy user prompt typically mixes three levels together:
|
|
48
|
+
|
|
49
|
+
- **Goal** (desired end state): "I want search results to show up in chat"
|
|
50
|
+
- **Tasks** (what to do): "add a postResult call, update the providers"
|
|
51
|
+
- **Constraints** (conditions/preferences): "don't break existing tests, use safeAsync"
|
|
52
|
+
|
|
53
|
+
Prompt formatting would parse raw input into structured components like:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
type ParsedTask = {
|
|
57
|
+
intent: string
|
|
58
|
+
targets: Array<string>
|
|
59
|
+
constraints: Array<string>
|
|
60
|
+
context?: string
|
|
61
|
+
subtasks: Array<ParsedTask>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type ParsedPrompt = {
|
|
65
|
+
tasks: Array<ParsedTask>
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The schema is recursive. A `ParsedTask` can contain subtasks, which can contain their own subtasks. This follows the HTN (Hierarchical Task Network) model where compound tasks decompose into subtask trees. A voice dump like "refactor the search module, add guards to each provider, make sure bsky and wiki get validated, then run the tests and fix anything that breaks" becomes:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
tasks:
|
|
73
|
+
- intent: refactor the search module
|
|
74
|
+
subtasks:
|
|
75
|
+
- intent: add guards to each provider
|
|
76
|
+
subtasks:
|
|
77
|
+
- intent: validate bsky responses
|
|
78
|
+
- intent: validate wiki responses
|
|
79
|
+
- intent: run the tests
|
|
80
|
+
subtasks:
|
|
81
|
+
- intent: fix any failures
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This is especially useful for voice input, where thoughts are unstructured, sentences run together, and a single utterance often contains an entire task tree.
|
|
85
|
+
|
|
86
|
+
**Status: implemented.** See [refine-prompt](#refine-prompt) below.
|
|
87
|
+
|
|
17
88
|
## Overview
|
|
18
89
|
|
|
19
|
-
|
|
90
|
+
The plugin takes raw instruction files and processes them through a two-step AI pipeline:
|
|
20
91
|
|
|
21
92
|
1. **Parse** - Converts raw text into structured rule components (strength, action, target, context, reason)
|
|
22
93
|
2. **Format** - Converts structured rules into one of three output modes: verbose, balanced, or concise
|
|
@@ -63,11 +134,11 @@ Reason: Arrow functions provide lexical this binding and a more compact syntax.
|
|
|
63
134
|
|
|
64
135
|
## Installation
|
|
65
136
|
|
|
66
|
-
Add
|
|
137
|
+
Add `opencode-sat` to your `opencode.json`:
|
|
67
138
|
|
|
68
139
|
```json
|
|
69
140
|
{
|
|
70
|
-
"plugin": ["opencode-
|
|
141
|
+
"plugin": ["opencode-sat"]
|
|
71
142
|
}
|
|
72
143
|
```
|
|
73
144
|
|
|
@@ -75,7 +146,7 @@ Restart OpenCode. The plugin will be installed automatically.
|
|
|
75
146
|
|
|
76
147
|
## Usage
|
|
77
148
|
|
|
78
|
-
The `
|
|
149
|
+
The `rewrite-instructions` tool reads the `instructions` array from your project's `opencode.json` and processes each matched file:
|
|
79
150
|
|
|
80
151
|
```json
|
|
81
152
|
{
|
|
@@ -83,27 +154,81 @@ The `irf-rewrite` tool reads the `instructions` array from your project's `openc
|
|
|
83
154
|
}
|
|
84
155
|
```
|
|
85
156
|
|
|
157
|
+
### rewrite-instructions
|
|
158
|
+
|
|
159
|
+
Rewrites all matched instruction files through the parse/format pipeline.
|
|
160
|
+
|
|
86
161
|
```
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
162
|
+
rewrite-instructions # discover from opencode.json, balanced mode
|
|
163
|
+
rewrite-instructions --mode concise # discover, concise output
|
|
164
|
+
rewrite-instructions --files fixtures/testing.md # single file, balanced mode
|
|
165
|
+
rewrite-instructions --files a.md,b.md --mode verbose # multiple files, verbose output
|
|
91
166
|
```
|
|
92
167
|
|
|
93
|
-
### Parameters
|
|
94
|
-
|
|
95
168
|
| Parameter | Type | Required | Description |
|
|
96
169
|
| --- | --- | --- | --- |
|
|
97
170
|
| `mode` | string | No | Output format: verbose, balanced, or concise (default: balanced) |
|
|
98
171
|
| `files` | string | No | Comma-separated file paths to process instead of discovering from opencode.json |
|
|
99
172
|
|
|
173
|
+
### add-instruction
|
|
174
|
+
|
|
175
|
+
Appends new rules to the end of an instruction file without rewriting existing content.
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
add-instruction --input "Always use early returns" # append to first discovered file, balanced mode
|
|
179
|
+
add-instruction --input "Use early returns" --mode concise
|
|
180
|
+
add-instruction --input "Use early returns" --file docs/rules.md
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
| Parameter | Type | Required | Description |
|
|
184
|
+
| --- | --- | --- | --- |
|
|
185
|
+
| `input` | string | Yes | Unstructured rule text to parse, format, and append |
|
|
186
|
+
| `file` | string | No | Target file path (default: first discovered instruction file) |
|
|
187
|
+
| `mode` | string | No | Output format: verbose, balanced, or concise (default: balanced) |
|
|
188
|
+
|
|
189
|
+
### automatic-rule
|
|
190
|
+
|
|
191
|
+
Automatically detects when the user corrects the agent's behavior or expresses a coding preference, extracts the implicit rule, and appends it to the instruction file. This tool is invoked automatically by the LLM, not by the user.
|
|
192
|
+
|
|
193
|
+
| Parameter | Type | Required | Description |
|
|
194
|
+
| --- | --- | --- | --- |
|
|
195
|
+
| `input` | string | Yes | The user's correction or feedback to extract a rule from |
|
|
196
|
+
| `file` | string | No | Target file path (default: first discovered instruction file) |
|
|
197
|
+
|
|
198
|
+
### refine-prompt
|
|
199
|
+
|
|
200
|
+
Restructures messy or unstructured user input into a clear, actionable task hierarchy. Takes raw text (often from voice transcription) and decomposes it into structured tasks with intent, targets, constraints, context, and recursive subtasks. Returns a formatted prompt the agent can act on.
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
refine-prompt --input "refactor the search module add guards to each provider make sure bsky and wiki get validated then run the tests and fix anything that breaks"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Output:
|
|
207
|
+
```
|
|
208
|
+
1. Refactor the search module
|
|
209
|
+
Targets: src/search.ts
|
|
210
|
+
- Add guards to each provider
|
|
211
|
+
Targets: src/providers/
|
|
212
|
+
- Validate bsky responses
|
|
213
|
+
Targets: bsky-search.ts
|
|
214
|
+
- Validate wiki responses
|
|
215
|
+
Targets: wiki-search.ts
|
|
216
|
+
|
|
217
|
+
2. Run the tests
|
|
218
|
+
Constraints: fix any failures
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
| Parameter | Type | Required | Description |
|
|
222
|
+
| --- | --- | --- | --- |
|
|
223
|
+
| `input` | string | Yes | Raw unstructured user input to restructure |
|
|
224
|
+
|
|
100
225
|
## Theoretical Foundation
|
|
101
226
|
|
|
102
|
-
|
|
227
|
+
The plugin is grounded in [speech act theory](https://en.wikipedia.org/wiki/Speech_act) and [deontic logic](https://en.wikipedia.org/wiki/Deontic_logic).
|
|
103
228
|
|
|
104
|
-
Instructions contain performative utterances that create obligations, permissions, and prohibitions.
|
|
229
|
+
Instructions contain performative utterances that create obligations, permissions, and prohibitions. The plugin identifies the illocutionary force of each instruction by extracting action verbs, target objects, contextual conditions, and justifications.
|
|
105
230
|
|
|
106
|
-
|
|
231
|
+
Deontic strengths:
|
|
107
232
|
|
|
108
233
|
- **Obligatory** - Required actions that create strong obligations
|
|
109
234
|
- **Forbidden** - Prohibited actions with clear boundaries
|
|
@@ -113,18 +238,6 @@ Rules are categorized using deontic strength:
|
|
|
113
238
|
- **Indifferent** - Actions with no normative preference
|
|
114
239
|
- **Omissible** - Actions that can be reasonably omitted
|
|
115
240
|
|
|
116
|
-
### Rule Schema
|
|
117
|
-
|
|
118
|
-
```ts
|
|
119
|
-
type ParsedRule = {
|
|
120
|
-
strength: 'obligatory' | 'forbidden' | 'permissible' | 'optional' | 'supererogatory' | 'indifferent' | 'omissible'
|
|
121
|
-
action: string
|
|
122
|
-
target: string
|
|
123
|
-
context?: string
|
|
124
|
-
reason: string
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
241
|
### Parsed Example
|
|
129
242
|
|
|
130
243
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sat.d.ts","sourceRoot":"","sources":["../sat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAGjD,QAAA,MAAM,MAAM,EAAE,MA8Db,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/dist/sat.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createAppendTool, createRefineTool, createRewriteTool } from "./src/tools.js";
|
|
2
|
+
const plugin = async ({ directory, client }) => {
|
|
3
|
+
const deps = { directory, client };
|
|
4
|
+
return {
|
|
5
|
+
tool: {
|
|
6
|
+
'rewrite-instructions': createRewriteTool({
|
|
7
|
+
deps,
|
|
8
|
+
description: [
|
|
9
|
+
'- Discover instruction files from opencode.json configuration.',
|
|
10
|
+
'- Parse discovered instruction files into structured rules.',
|
|
11
|
+
'- Format structured rules into human-readable rules.',
|
|
12
|
+
'- Write formatted rules back to the original instruction files.',
|
|
13
|
+
'- Optionally accept a mode parameter (verbose, balanced, or concise) to control formatting.',
|
|
14
|
+
'- Default to balanced mode when no mode is specified.',
|
|
15
|
+
'- Optionally accept a files parameter to process specific files instead of running discovery.',
|
|
16
|
+
].join('\n'),
|
|
17
|
+
}),
|
|
18
|
+
'add-instruction': createAppendTool({
|
|
19
|
+
deps,
|
|
20
|
+
toolName: 'add-instruction',
|
|
21
|
+
sessionTitle: 'SAT Add',
|
|
22
|
+
defaultMode: 'balanced',
|
|
23
|
+
hasMode: true,
|
|
24
|
+
successPrefix: 'Added',
|
|
25
|
+
description: [
|
|
26
|
+
'- Parse unstructured input into structured rules.',
|
|
27
|
+
'- Format parsed rules after parsing unstructured input into structured rules.',
|
|
28
|
+
'- Append formatted rules to the instruction file without rewriting existing content.',
|
|
29
|
+
'- Optionally accept a mode parameter (verbose, balanced, or concise).',
|
|
30
|
+
'- Default mode to balanced when no mode parameter is specified.',
|
|
31
|
+
'- Optionally accept a file parameter to specify the target instruction file.',
|
|
32
|
+
'- Append to the first discovered instruction file when no file parameter is specified.',
|
|
33
|
+
].join('\n'),
|
|
34
|
+
}),
|
|
35
|
+
'automatic-rule': createAppendTool({
|
|
36
|
+
deps,
|
|
37
|
+
toolName: 'automatic-rule',
|
|
38
|
+
sessionTitle: 'SAT Candidate',
|
|
39
|
+
defaultMode: 'balanced',
|
|
40
|
+
hasMode: false,
|
|
41
|
+
successPrefix: 'Learned',
|
|
42
|
+
description: [
|
|
43
|
+
'- Detect user corrections when the user says something was done wrong, expresses a preference about how code should be written, or gives feedback that implies a repeatable guideline.',
|
|
44
|
+
'- Extract the implicit rule from the correction after detecting a user correction or preference.',
|
|
45
|
+
'- Persist the extracted rule as a new instruction rule.',
|
|
46
|
+
'- Append the new rule to the instruction file.',
|
|
47
|
+
].join('\n'),
|
|
48
|
+
}),
|
|
49
|
+
'refine-prompt': createRefineTool({
|
|
50
|
+
deps,
|
|
51
|
+
description: [
|
|
52
|
+
'- Restructure messy, ambiguous, or voice-transcribed user input before starting work when the message is vague, run-on, contains multiple interleaved requests, or reads like unpunctuated speech.',
|
|
53
|
+
'- Invoke this tool BEFORE starting work on vague, run-on, multi-request, or speech-like user messages.',
|
|
54
|
+
'- Decompose the input into a hierarchical task breakdown when restructuring user input.',
|
|
55
|
+
'- Return formatted markdown after decomposing the input.',
|
|
56
|
+
].join('\n'),
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export default plugin;
|
|
62
|
+
//# sourceMappingURL=sat.js.map
|
package/dist/sat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ACb,CAAC;YAEF,eAAe,EAAE,gBAAgB,CAAC;gBAChC,IAAI;gBACJ,WAAW,EAAE;oBACX,oMAAoM;oBACpM,wGAAwG;oBACxG,yFAAyF;oBACzF,0DAA0D;iBAC3D,CAAC,IAAI,CAAC,IAAI,CAAC;aACb,CAAC;SACH;KACF,CAAA;AACH,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/dist/src/append.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { buildFormatPrompt, buildParsePrompt } from './prompt';
|
|
4
|
-
import { FormatResponseSchema, ParseResponseSchema } from './schema';
|
|
4
|
+
import { FormatResponseSchema, ParseResponseSchema } from './rule-schema';
|
|
5
5
|
import { safeAsync } from './utils/safe';
|
|
6
6
|
// parse unstructured input, format it, and append to end of file
|
|
7
7
|
export const appendRules = async (options) => {
|
package/dist/src/append.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../src/append.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../src/append.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,oBAAoB,EAAE,mBAA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eAAO,MAAM,YAAY,GAAI,QAAQ,YAAY,KAAG,MAiBnD,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const formatTask = (options) => {
|
|
2
|
+
const { task, index, depth } = options;
|
|
3
|
+
const indent = ' '.repeat(depth);
|
|
4
|
+
const number = depth === 0 ? String(index + 1) + '.' : '-';
|
|
5
|
+
const lines = [];
|
|
6
|
+
lines.push(indent + number + ' ' + task.intent);
|
|
7
|
+
if (task.targets.length > 0) {
|
|
8
|
+
lines.push(indent + ' Targets: ' + task.targets.join(', '));
|
|
9
|
+
}
|
|
10
|
+
if (task.constraints.length > 0) {
|
|
11
|
+
lines.push(indent + ' Constraints: ' + task.constraints.join(', '));
|
|
12
|
+
}
|
|
13
|
+
if (task.context) {
|
|
14
|
+
lines.push(indent + ' Context: ' + task.context);
|
|
15
|
+
}
|
|
16
|
+
for (let i = 0; i < task.subtasks.length; i++) {
|
|
17
|
+
const subtask = task.subtasks[i];
|
|
18
|
+
if (!subtask) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
lines.push(formatTask({
|
|
22
|
+
task: subtask,
|
|
23
|
+
index: i,
|
|
24
|
+
depth: depth + 1,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
return lines.join('\n');
|
|
28
|
+
};
|
|
29
|
+
export const formatPrompt = (parsed) => {
|
|
30
|
+
const lines = [];
|
|
31
|
+
for (let i = 0; i < parsed.tasks.length; i++) {
|
|
32
|
+
const task = parsed.tasks[i];
|
|
33
|
+
if (!task) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
lines.push(formatTask({
|
|
37
|
+
task,
|
|
38
|
+
index: i,
|
|
39
|
+
depth: 0,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
return lines.join('\n\n');
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=format-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-prompt.js","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AC,OAAO,EAAE,CAAC;YACb,SAAQ;QACV,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;YACpB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,KAAK,GAAG,CAAC;SACjB,CAAC,CAAC,CAAA;IACL,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAoB,EAAU,EAAE;IAC3D,MAAM,KAAK,GAAkB,EAAE,CAAA;IAE/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,SAAQ;QACV,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;YACpB,IAAI;YACJ,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,CAAC;SACT,CAAC,CAAC,CAAA;IACL,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { Result } from './utils/safe';
|
|
3
|
+
import type { ParsedPrompt } from './prompt-schema';
|
|
4
|
+
type PromptFn = <T>(prompt: string, schema: z.ZodType<T>) => Promise<Result<T>>;
|
|
5
|
+
type ProcessPromptOptions = {
|
|
6
|
+
input: string;
|
|
7
|
+
prompt: PromptFn;
|
|
8
|
+
};
|
|
9
|
+
type PromptResult = {
|
|
10
|
+
status: 'success';
|
|
11
|
+
formatted: string;
|
|
12
|
+
parsed: ParsedPrompt;
|
|
13
|
+
} | {
|
|
14
|
+
status: 'parseError';
|
|
15
|
+
error: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const processPrompt: (options: ProcessPromptOptions) => Promise<PromptResult>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=process-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-prompt.d.ts","sourceRoot":"","sources":["../../src/process-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAKnD,KAAK,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/E,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,QAAQ,CAAA;CACjB,CAAA;AAED,KAAK,YAAY,GACb;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,GAC9D;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3C,eAAO,MAAM,aAAa,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,YAAY,CAiBvF,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ParsedPromptSchema } from './prompt-schema';
|
|
2
|
+
import { buildPromptParsePrompt } from './prompt-prompt';
|
|
3
|
+
import { formatPrompt } from './format-prompt';
|
|
4
|
+
export const processPrompt = async (options) => {
|
|
5
|
+
const { input, prompt } = options;
|
|
6
|
+
const parsePrompt = buildPromptParsePrompt(input);
|
|
7
|
+
const parseResult = await prompt(parsePrompt, ParsedPromptSchema);
|
|
8
|
+
if (parseResult.error) {
|
|
9
|
+
return { status: 'parseError', error: parseResult.error };
|
|
10
|
+
}
|
|
11
|
+
if (!parseResult.data) {
|
|
12
|
+
return { status: 'parseError', error: 'Parse returned no data' };
|
|
13
|
+
}
|
|
14
|
+
const formatted = formatPrompt(parseResult.data);
|
|
15
|
+
return { status: 'success', formatted, parsed: parseResult.data };
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=process-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-prompt.js","sourceRoot":"","sources":["../../src/process-prompt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAa9C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,OAA6B,EAAyB,EAAE;IAC1F,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAEjC,MAAM,WAAW,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAA;IACjD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAA;IAEjE,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,CAAA;IAC3D,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAA;IAClE,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAEhD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAA;AACnE,CAAC,CAAA"}
|
package/dist/src/process.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises';
|
|
2
2
|
import { basename } from 'node:path';
|
|
3
3
|
import { buildFormatPrompt, buildParsePrompt } from './prompt';
|
|
4
|
-
import { FormatResponseSchema, ParseResponseSchema } from './schema';
|
|
4
|
+
import { FormatResponseSchema, ParseResponseSchema } from './rule-schema';
|
|
5
5
|
import { compareBytes } from './utils/compare';
|
|
6
6
|
import { safeAsync } from './utils/safe';
|
|
7
7
|
// process a single instruction file through the parse -> format -> write pipeline
|
package/dist/src/process.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACzE,OAAO,EAAE,YAAY,EAAyB,MAAM,iBAAiB,CAAA;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AA0BxC,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,OAA2B,E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AE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAC3F,IAAI,UAAU,EAAE,CAAC;QACf,OAAO;YACL,MAAM,EAAE,YAAY;YACpB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,UAAU,CAAC,OAAO;SAC1B,CAAA;IACH,CAAC;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC3E,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,UAAU,EAAE,cAAc,CAAC,MAAM;QACjC,UAAU;KACX,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-prompt.d.ts","sourceRoot":"","sources":["../../src/prompt-prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,KAAG,MAoCtD,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,cAAc,MAAM,KAAG,MAQ7D,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { promptSchemaExample } from './prompt-schema';
|
|
2
|
+
export const buildPromptParsePrompt = (input) => {
|
|
3
|
+
const instructions = [
|
|
4
|
+
'You are a prompt structuring system.',
|
|
5
|
+
'Your job is to take raw, unstructured user input and decompose it into a structured task hierarchy.',
|
|
6
|
+
'The input may be messy, from voice transcription, contain filler words, or have multiple requests mixed together.',
|
|
7
|
+
'',
|
|
8
|
+
'Decompose the input into tasks. Each task has:',
|
|
9
|
+
'- intent: a clear, concise directive (what to do)',
|
|
10
|
+
'- targets: files, systems, or things involved (array, can be empty)',
|
|
11
|
+
'- constraints: conditions, preferences, or requirements (array, can be empty)',
|
|
12
|
+
'- context: optional background info or rationale',
|
|
13
|
+
'- subtasks: recursive array of child tasks (empty if the task is a leaf)',
|
|
14
|
+
'',
|
|
15
|
+
'Guidelines:',
|
|
16
|
+
'- Extract the actual intent behind the words, not the words themselves.',
|
|
17
|
+
'- Separate compound requests into multiple top-level tasks.',
|
|
18
|
+
'- When a task has clear sub-steps, decompose into subtasks.',
|
|
19
|
+
'- Preserve specific file names, variable names, and technical terms exactly as stated.',
|
|
20
|
+
'- Drop filler words, false starts, and verbal noise.',
|
|
21
|
+
'- If the user mentions constraints or preferences, attach them to the relevant task.',
|
|
22
|
+
'- If context or rationale is provided, capture it in the context field.',
|
|
23
|
+
'- Keep intents as imperative directives (start with a verb).',
|
|
24
|
+
'',
|
|
25
|
+
'Return JSON matching this schema:',
|
|
26
|
+
promptSchemaExample,
|
|
27
|
+
'',
|
|
28
|
+
'Return ONLY valid JSON.',
|
|
29
|
+
'Do not wrap the response in markdown code fences.',
|
|
30
|
+
];
|
|
31
|
+
return [
|
|
32
|
+
instructions.join('\n'),
|
|
33
|
+
'---',
|
|
34
|
+
'User input:',
|
|
35
|
+
input,
|
|
36
|
+
].join('\n');
|
|
37
|
+
};
|
|
38
|
+
export const buildPromptRetryPrompt = (errorMessage) => {
|
|
39
|
+
return [
|
|
40
|
+
'The previous response failed validation:',
|
|
41
|
+
errorMessage,
|
|
42
|
+
'',
|
|
43
|
+
'Return ONLY valid JSON matching the schema.',
|
|
44
|
+
'Do not wrap the response in markdown code fences.',
|
|
45
|
+
].join('\n');
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=prompt-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-prompt.js","sourceRoot":"","sources":["../../src/prompt-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC9D,MAAM,YAAY,GAAG;QACnB,sCAAsC;QACtC,qGAAqG;QACrG,mHAAmH;QACnH,EAAE;QACF,gDAAgD;QAChD,mDAAmD;QACnD,qEAAqE;QACrE,+EAA+E;QAC/E,kDAAkD;QAClD,0EAA0E;QAC1E,EAAE;QACF,aAAa;QACb,yEAAyE;QACzE,6DAA6D;QAC7D,6DAA6D;QAC7D,wFAAwF;QACxF,sDAAsD;QACtD,sFAAsF;QACtF,yEAAyE;QACzE,8DAA8D;QAC9D,EAAE;QACF,mCAAmC;QACnC,mBAAmB;QACnB,EAAE;QACF,yBAAyB;QACzB,mDAAmD;KACpD,CAAA;IAED,OAAO;QACL,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QACvB,KAAK;QACL,aAAa;QACb,KAAK;KACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,YAAoB,EAAU,EAAE;IACrE,OAAO;QACL,0CAA0C;QAC1C,YAAY;QACZ,EAAE;QACF,6CAA6C;QAC7C,mDAAmD;KACpD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const IntentSchema: z.ZodString;
|
|
3
|
+
export declare const TaskTargetsSchema: z.ZodArray<z.ZodString>;
|
|
4
|
+
export declare const ConstraintsSchema: z.ZodArray<z.ZodString>;
|
|
5
|
+
export declare const TaskContextSchema: z.ZodString;
|
|
6
|
+
export declare const ParsedTaskSchema: z.ZodType<ParsedTask>;
|
|
7
|
+
export declare const ParsedPromptSchema: z.ZodObject<{
|
|
8
|
+
tasks: z.ZodArray<z.ZodType<ParsedTask, unknown, z.core.$ZodTypeInternals<ParsedTask, unknown>>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const FormattedPromptSchema: z.ZodObject<{
|
|
11
|
+
prompt: z.ZodString;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type ParsedTask = {
|
|
14
|
+
intent: string;
|
|
15
|
+
targets: Array<string>;
|
|
16
|
+
constraints: Array<string>;
|
|
17
|
+
context?: string;
|
|
18
|
+
subtasks: Array<ParsedTask>;
|
|
19
|
+
};
|
|
20
|
+
export type ParsedPrompt = z.infer<typeof ParsedPromptSchema>;
|
|
21
|
+
export declare const promptSchemaExample: string;
|
|
22
|
+
//# sourceMappingURL=prompt-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-schema.d.ts","sourceRoot":"","sources":["../../src/prompt-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,YAAY,aACgC,CAAA;AAEzD,eAAO,MAAM,iBAAiB,yBACmB,CAAA;AAEjD,eAAO,MAAM,iBAAiB,yBACyB,CAAA;AAEvD,eAAO,MAAM,iBAAiB,aAC0B,CAAA;AAExD,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAOkB,CAAA;AAErE,eAAO,MAAM,kBAAkB;;iBAE7B,CAAA;AAEF,eAAO,MAAM,qBAAqB;;iBAEhC,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACtB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAE7D,eAAO,MAAM,mBAAmB,QAQ9B,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const IntentSchema = z.string()
|
|
3
|
+
.describe('What to do, expressed as a clear directive');
|
|
4
|
+
export const TaskTargetsSchema = z.array(z.string())
|
|
5
|
+
.describe('Files, systems, or things involved');
|
|
6
|
+
export const ConstraintsSchema = z.array(z.string())
|
|
7
|
+
.describe('Conditions, preferences, or requirements');
|
|
8
|
+
export const TaskContextSchema = z.string()
|
|
9
|
+
.describe('Background info or rationale for the task');
|
|
10
|
+
export const ParsedTaskSchema = z.object({
|
|
11
|
+
intent: IntentSchema,
|
|
12
|
+
targets: TaskTargetsSchema.default([]),
|
|
13
|
+
constraints: ConstraintsSchema.default([]),
|
|
14
|
+
context: TaskContextSchema.optional(),
|
|
15
|
+
subtasks: z.lazy(() => z.array(ParsedTaskSchema)).default([]),
|
|
16
|
+
})
|
|
17
|
+
.describe('Single task decomposed into action/planning components');
|
|
18
|
+
export const ParsedPromptSchema = z.object({
|
|
19
|
+
tasks: z.array(ParsedTaskSchema),
|
|
20
|
+
});
|
|
21
|
+
export const FormattedPromptSchema = z.object({
|
|
22
|
+
prompt: z.string().describe('Human-readable restructured prompt'),
|
|
23
|
+
});
|
|
24
|
+
export const promptSchemaExample = JSON.stringify({
|
|
25
|
+
tasks: [{
|
|
26
|
+
intent: IntentSchema.description || 'directive',
|
|
27
|
+
targets: [TaskTargetsSchema.element.description || 'file or system'],
|
|
28
|
+
constraints: [ConstraintsSchema.element.description || 'requirement'],
|
|
29
|
+
context: TaskContextSchema.description || 'optional background',
|
|
30
|
+
subtasks: [],
|
|
31
|
+
}],
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=prompt-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-schema.js","sourceRoot":"","sources":["../../src/prompt-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE;KACn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AM,EAAE,YAAY,CAAC,WAAW,IAAI,WAAW;YAC/C,OAAO,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,IAAI,gBAAgB,CAAC;YACpE,WAAW,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,IAAI,aAAa,CAAC;YACrE,OAAO,EAAE,iBAAiB,CAAC,WAAW,IAAI,qBAAqB;YAC/D,QAAQ,EAAE,EAAE;SACb,CAAC;CACH,CAAC,CAAA"}
|
package/dist/src/prompt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseSchemaExample } from './schema';
|
|
1
|
+
import { parseSchemaExample } from './rule-schema';
|
|
2
2
|
export const FORMAT_MODES = ['verbose', 'balanced', 'concise'];
|
|
3
3
|
export const isFormatMode = (v) => typeof v === 'string' && FORMAT_MODES.includes(v);
|
|
4
4
|
export const buildParsePrompt = (input) => {
|
package/dist/src/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAIlD,MAAM,CAAC,MAAM,YAAY,GAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;AAE5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAU,EAAmB,EAAE,CAC1D,OAAO,CAAC,KAAK,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAe,CAAC,CAAA;AAEjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE;IACxD,MAAM,YAAY,GAAG;QACnB,oFAAoF;QACpF,gFAAgF;QAChF,kIAAkI;QAClI,uEAAuE;QACvE,EA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AAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxD,OAAO,CAAC,YAAY,EAAE,0BAA0B,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACjF,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,YAAoB,EAAU,EAAE;IAC/D,OAAO,sCAAsC,GAAG,YAAY;UACxD,8EAA8E,CAAA;AACpF,CAAC,CAAA"}
|
|
@@ -66,4 +66,4 @@ export declare const FormatResponseSchema: z.ZodObject<{
|
|
|
66
66
|
export type Strength = z.infer<typeof StrengthSchema>;
|
|
67
67
|
export type ParsedRule = z.infer<typeof ParsedRuleSchema>;
|
|
68
68
|
export declare const parseSchemaExample: string;
|
|
69
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
69
|
+
//# sourceMappingURL=rule-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-schema.d.ts","sourceRoot":"","sources":["../../src/rule-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,cAAc;;;;;;;;EASoC,CAAA;AAE/D,eAAO,MAAM,YAAY,aACmC,CAAA;AAE5D,eAAO,MAAM,YAAY,aAC6B,CAAA;AAEtD,eAAO,MAAM,aAAa,aAC4C,CAAA;AAEtE,eAAO,MAAM,YAAY,aAC2B,CAAA;AAEpD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;iBAOuC,CAAA;AAEpE,eAAO,MAAM,UAAU,aAC0C,CAAA;AAEjE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;kBACW,CAAA;AAEpC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;iBAE9B,CAAA;AAEF,eAAO,MAAM,oBAAoB;;iBAE/B,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,eAAO,MAAM,kBAAkB,QAQ7B,CAAA"}
|
|
@@ -35,7 +35,6 @@ export const ParseResponseSchema = z.object({
|
|
|
35
35
|
export const FormatResponseSchema = z.object({
|
|
36
36
|
rules: z.array(RuleSchema),
|
|
37
37
|
});
|
|
38
|
-
// generate a JSON schema example string from the Zod schema for use in prompts
|
|
39
38
|
export const parseSchemaExample = JSON.stringify({
|
|
40
39
|
rules: [{
|
|
41
40
|
strength: StrengthSchema.options.join('/'),
|
|
@@ -45,4 +44,4 @@ export const parseSchemaExample = JSON.stringify({
|
|
|
45
44
|
reason: ReasonSchema.description || 'justification',
|
|
46
45
|
}],
|
|
47
46
|
});
|
|
48
|
-
//# sourceMappingURL=schema.js.map
|
|
47
|
+
//# sourceMappingURL=rule-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-schema.js","sourceRoot":"","sources":["../../src/rule-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC;IACnC,YAAY;IACZ,aAAa;IACb,WAAW;IACX,UAAU;IACV,gBAAgB;IAChB,aAAa;IACb,WAAW;CACZ,CAAC;KACC,QAAQ,CAAC,kDAAkD,CAAC,CAAA;AAE/D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE;KACnC,QAAQ,CAAC,+CAA+C,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE;KACnC,QAAQ,CAAC,yCAAyC,CAAC,CAAA;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE;KACpC,QAAQ,CAAC,yDAAyD,CAAC,CAAA;AAEtE,MAAM,CAAC,M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from '@opencode-ai/plugin';
|
|
2
|
+
import { type FormatMode } from './prompt.ts';
|
|
3
|
+
type Client = PluginInput['client'];
|
|
4
|
+
type ToolDeps = {
|
|
5
|
+
directory: string;
|
|
6
|
+
client: Client;
|
|
7
|
+
};
|
|
8
|
+
type RewriteToolOptions = {
|
|
9
|
+
description: string;
|
|
10
|
+
deps: ToolDeps;
|
|
11
|
+
};
|
|
12
|
+
export declare const createRewriteTool: (options: RewriteToolOptions) => {
|
|
13
|
+
description: string;
|
|
14
|
+
args: {
|
|
15
|
+
mode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
16
|
+
files: import("zod").ZodOptional<import("zod").ZodString>;
|
|
17
|
+
};
|
|
18
|
+
execute(args: {
|
|
19
|
+
mode?: string | undefined;
|
|
20
|
+
files?: string | undefined;
|
|
21
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
22
|
+
};
|
|
23
|
+
type AppendToolOptions = {
|
|
24
|
+
description: string;
|
|
25
|
+
deps: ToolDeps;
|
|
26
|
+
toolName: string;
|
|
27
|
+
sessionTitle: string;
|
|
28
|
+
defaultMode: FormatMode;
|
|
29
|
+
successPrefix: string;
|
|
30
|
+
hasMode: boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare const createAppendTool: (options: AppendToolOptions) => {
|
|
33
|
+
description: string;
|
|
34
|
+
args: {
|
|
35
|
+
mode?: import("zod").ZodOptional<import("zod").ZodString> | undefined;
|
|
36
|
+
input: import("zod").ZodString;
|
|
37
|
+
file: import("zod").ZodOptional<import("zod").ZodString>;
|
|
38
|
+
};
|
|
39
|
+
execute(args: {
|
|
40
|
+
mode?: unknown;
|
|
41
|
+
input: string;
|
|
42
|
+
file?: string | undefined;
|
|
43
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
44
|
+
};
|
|
45
|
+
type RefineToolOptions = {
|
|
46
|
+
description: string;
|
|
47
|
+
deps: ToolDeps;
|
|
48
|
+
};
|
|
49
|
+
export declare const createRefineTool: (options: RefineToolOptions) => {
|
|
50
|
+
description: string;
|
|
51
|
+
args: {
|
|
52
|
+
input: import("zod").ZodString;
|
|
53
|
+
};
|
|
54
|
+
execute(args: {
|
|
55
|
+
input: string;
|
|
56
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAOtD,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,aAAa,CAAA;AAM3D,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAA;AAEnC,KAAK,QAAQ,GAAG;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAkED,KAAK,kBAAkB,GAAG;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS,kBAAkB;;;;;;;;;;CA8D5D,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,UAAU,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;CAgF1D,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,iBAAiB;;;;;;;;CA4C1D,CAAA"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { tool } from '@opencode-ai/plugin';
|
|
2
|
+
import { basename } from 'node:path';
|
|
3
|
+
import { appendRules } from "./append.js";
|
|
4
|
+
import { sendResult } from "./opencode/notify.js";
|
|
5
|
+
import { processFile } from "./process.js";
|
|
6
|
+
import { processPrompt } from "./process-prompt.js";
|
|
7
|
+
import { isFormatMode } from "./prompt.js";
|
|
8
|
+
import { resolveFiles } from "./resolve.js";
|
|
9
|
+
import { detectModel, promptWithRetry } from "./session.js";
|
|
10
|
+
import { buildTable } from "./utils/compare.js";
|
|
11
|
+
import { safeAsync } from "./utils/safe.js";
|
|
12
|
+
const ERROR_LABELS = {
|
|
13
|
+
readError: 'Read failed',
|
|
14
|
+
parseError: 'Parse failed',
|
|
15
|
+
formatError: 'Format failed',
|
|
16
|
+
writeError: 'Write failed',
|
|
17
|
+
};
|
|
18
|
+
const toTableRow = (result) => {
|
|
19
|
+
if (result.status === 'success') {
|
|
20
|
+
return {
|
|
21
|
+
file: basename(result.path),
|
|
22
|
+
status: 'Success',
|
|
23
|
+
rules: result.rulesCount,
|
|
24
|
+
comparison: result.comparison,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const label = ERROR_LABELS[result.status] || result.status;
|
|
28
|
+
return {
|
|
29
|
+
file: basename(result.path),
|
|
30
|
+
status: label,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const createSession = async (options) => {
|
|
34
|
+
const { client, sessionID, title, toolName } = options;
|
|
35
|
+
const model = await detectModel(client, sessionID);
|
|
36
|
+
if (!model) {
|
|
37
|
+
return { ok: false, error: 'Could not detect current model. Send a message first, then call ' + toolName + '.' };
|
|
38
|
+
}
|
|
39
|
+
const sessionResult = await client.session.create({ body: { title } });
|
|
40
|
+
if (!sessionResult.data) {
|
|
41
|
+
return { ok: false, error: 'Failed to create internal session' };
|
|
42
|
+
}
|
|
43
|
+
const sessionId = sessionResult.data.id;
|
|
44
|
+
const prompt = (text, schema) => (promptWithRetry({
|
|
45
|
+
client,
|
|
46
|
+
sessionId,
|
|
47
|
+
initialPrompt: text,
|
|
48
|
+
schema,
|
|
49
|
+
model,
|
|
50
|
+
}));
|
|
51
|
+
return { ok: true, sessionId, prompt };
|
|
52
|
+
};
|
|
53
|
+
export const createRewriteTool = (options) => {
|
|
54
|
+
const { description, deps } = options;
|
|
55
|
+
const { directory, client } = deps;
|
|
56
|
+
return tool({
|
|
57
|
+
description,
|
|
58
|
+
args: {
|
|
59
|
+
mode: tool.schema.string().optional().describe('Output format: verbose, balanced, or concise (default: balanced)'),
|
|
60
|
+
files: tool.schema.string().optional().describe('Comma-separated file paths to process instead of discovering from opencode.json'),
|
|
61
|
+
},
|
|
62
|
+
async execute(args, context) {
|
|
63
|
+
const mode = isFormatMode(args.mode) ? args.mode : 'balanced';
|
|
64
|
+
try {
|
|
65
|
+
const resolved = await resolveFiles(directory, args.files);
|
|
66
|
+
if (resolved.error !== null) {
|
|
67
|
+
return resolved.error;
|
|
68
|
+
}
|
|
69
|
+
const session = await createSession({
|
|
70
|
+
client,
|
|
71
|
+
sessionID: context.sessionID,
|
|
72
|
+
title: 'SAT Rewrite',
|
|
73
|
+
toolName: 'rewrite-instructions',
|
|
74
|
+
});
|
|
75
|
+
if (!session.ok) {
|
|
76
|
+
return session.error;
|
|
77
|
+
}
|
|
78
|
+
const fileResults = [];
|
|
79
|
+
for (const file of resolved.data) {
|
|
80
|
+
if (context.abort.aborted) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
fileResults.push(await processFile({ file, prompt: session.prompt, mode }));
|
|
84
|
+
}
|
|
85
|
+
await safeAsync(() => client.session.delete({ path: { id: session.sessionId } }));
|
|
86
|
+
const table = buildTable(fileResults.map(toTableRow));
|
|
87
|
+
if (table.length > 0) {
|
|
88
|
+
await sendResult({
|
|
89
|
+
client,
|
|
90
|
+
sessionID: context.sessionID,
|
|
91
|
+
text: table,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return table;
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
98
|
+
return 'rewrite-instructions error: ' + msg;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
export const createAppendTool = (options) => {
|
|
104
|
+
const { description, deps, toolName, sessionTitle, defaultMode, successPrefix, hasMode } = options;
|
|
105
|
+
const { directory, client } = deps;
|
|
106
|
+
return tool({
|
|
107
|
+
description,
|
|
108
|
+
args: {
|
|
109
|
+
input: tool.schema.string().describe('Unstructured text describing the rule(s) to add'),
|
|
110
|
+
file: tool.schema.string().optional().describe('File path to append to. If omitted, uses the first discovered instruction file.'),
|
|
111
|
+
...(hasMode
|
|
112
|
+
? {
|
|
113
|
+
mode: tool.schema.string().optional().describe('Output format: verbose, balanced, or concise (default: balanced)'),
|
|
114
|
+
}
|
|
115
|
+
: {}),
|
|
116
|
+
},
|
|
117
|
+
async execute(args, context) {
|
|
118
|
+
const mode = hasMode && isFormatMode(args.mode) ? args.mode : defaultMode;
|
|
119
|
+
try {
|
|
120
|
+
let filePath = args.file;
|
|
121
|
+
if (!filePath) {
|
|
122
|
+
const resolved = await resolveFiles(directory);
|
|
123
|
+
if (resolved.error !== null) {
|
|
124
|
+
return resolved.error;
|
|
125
|
+
}
|
|
126
|
+
const first = resolved.data[0];
|
|
127
|
+
if (!first) {
|
|
128
|
+
return 'No instruction files found in opencode.json';
|
|
129
|
+
}
|
|
130
|
+
filePath = first.path;
|
|
131
|
+
}
|
|
132
|
+
const session = await createSession({
|
|
133
|
+
client,
|
|
134
|
+
sessionID: context.sessionID,
|
|
135
|
+
title: sessionTitle,
|
|
136
|
+
toolName,
|
|
137
|
+
});
|
|
138
|
+
if (!session.ok) {
|
|
139
|
+
return session.error;
|
|
140
|
+
}
|
|
141
|
+
const result = await appendRules({
|
|
142
|
+
input: args.input,
|
|
143
|
+
filePath,
|
|
144
|
+
directory,
|
|
145
|
+
prompt: session.prompt,
|
|
146
|
+
mode,
|
|
147
|
+
});
|
|
148
|
+
await safeAsync(() => client.session.delete({ path: { id: session.sessionId } }));
|
|
149
|
+
if (result.status !== 'success') {
|
|
150
|
+
return result.status + ': ' + result.error;
|
|
151
|
+
}
|
|
152
|
+
const msg = successPrefix + result.rulesCount + ' rule(s) to ' + result.path;
|
|
153
|
+
await sendResult({
|
|
154
|
+
client,
|
|
155
|
+
sessionID: context.sessionID,
|
|
156
|
+
text: msg,
|
|
157
|
+
});
|
|
158
|
+
return msg;
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
162
|
+
return toolName + ' error: ' + msg;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
export const createRefineTool = (options) => {
|
|
168
|
+
const { description, deps } = options;
|
|
169
|
+
const { client } = deps;
|
|
170
|
+
return tool({
|
|
171
|
+
description,
|
|
172
|
+
args: {
|
|
173
|
+
input: tool.schema.string().describe('Raw unstructured user input to refine into a structured prompt'),
|
|
174
|
+
},
|
|
175
|
+
async execute(args, context) {
|
|
176
|
+
try {
|
|
177
|
+
const session = await createSession({
|
|
178
|
+
client,
|
|
179
|
+
sessionID: context.sessionID,
|
|
180
|
+
title: 'SAT Refine',
|
|
181
|
+
toolName: 'refine-prompt',
|
|
182
|
+
});
|
|
183
|
+
if (!session.ok) {
|
|
184
|
+
return session.error;
|
|
185
|
+
}
|
|
186
|
+
const result = await processPrompt({ input: args.input, prompt: session.prompt });
|
|
187
|
+
await safeAsync(() => client.session.delete({ path: { id: session.sessionId } }));
|
|
188
|
+
if (result.status !== 'success') {
|
|
189
|
+
return 'refine-prompt parse error: ' + result.error;
|
|
190
|
+
}
|
|
191
|
+
await sendResult({
|
|
192
|
+
client,
|
|
193
|
+
sessionID: context.sessionID,
|
|
194
|
+
text: result.formatted,
|
|
195
|
+
});
|
|
196
|
+
return result.formatted;
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
200
|
+
return 'refine-prompt error: ' + msg;
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAmB,WAAW,EAAiB,MAAM,cAAc,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAmB,YAAY,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAS3C,MAAM,YAAY,GAA2B;IAC3C,SAAS,EAAE,aAAa;IACxB,UAAU,EAAE,cAAc;IAC1B,WAAW,EAAE,eAAe;IAC5B,UAAU,EAAE,cAAc;CAC3B,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAY,EAAE;IAClD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;Y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AC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAC5D,OAAO,uBAAuB,GAAG,GAAG,CAAA;YACtC,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-irf",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12-next.1",
|
|
4
4
|
"description": "OpenCode plugin that converts unstructured instructions into structured rules using speech act theory and deontic logic.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"type": "module",
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
|
-
"import": "./dist/
|
|
29
|
-
"types": "./dist/
|
|
28
|
+
"import": "./dist/sat.js",
|
|
29
|
+
"types": "./dist/sat.d.ts"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
-
"main": "./dist/
|
|
33
|
-
"types": "./dist/
|
|
32
|
+
"main": "./dist/sat.js",
|
|
33
|
+
"types": "./dist/sat.d.ts",
|
|
34
34
|
"files": [
|
|
35
35
|
"dist/",
|
|
36
36
|
"README.md",
|
package/dist/irf.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"irf.d.ts","sourceRoot":"","sources":["../irf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAoCjD,QAAA,MAAM,MAAM,EAAE,MAuLb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/dist/irf.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { tool } from '@opencode-ai/plugin';
|
|
2
|
-
import { basename } from 'node:path';
|
|
3
|
-
import { appendRules } from "./src/append.js";
|
|
4
|
-
import { sendResult } from "./src/opencode/notify.js";
|
|
5
|
-
import { processFile } from "./src/process.js";
|
|
6
|
-
import { isFormatMode } from "./src/prompt.js";
|
|
7
|
-
import { resolveFiles } from "./src/resolve.js";
|
|
8
|
-
import { detectModel, promptWithRetry } from "./src/session.js";
|
|
9
|
-
import { buildTable } from "./src/utils/compare.js";
|
|
10
|
-
import { safeAsync } from "./src/utils/safe.js";
|
|
11
|
-
const ERROR_LABELS = {
|
|
12
|
-
readError: 'Read failed',
|
|
13
|
-
parseError: 'Parse failed',
|
|
14
|
-
formatError: 'Format failed',
|
|
15
|
-
writeError: 'Write failed',
|
|
16
|
-
};
|
|
17
|
-
const toTableRow = (result) => {
|
|
18
|
-
if (result.status === 'success') {
|
|
19
|
-
return {
|
|
20
|
-
file: basename(result.path),
|
|
21
|
-
status: 'Success',
|
|
22
|
-
rules: result.rulesCount,
|
|
23
|
-
comparison: result.comparison,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const label = ERROR_LABELS[result.status] || result.status;
|
|
27
|
-
return {
|
|
28
|
-
file: basename(result.path),
|
|
29
|
-
status: label,
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
const plugin = async ({ directory, client }) => {
|
|
33
|
-
return {
|
|
34
|
-
tool: {
|
|
35
|
-
'irf-rewrite': tool({
|
|
36
|
-
description: [
|
|
37
|
-
'Discover instruction files from opencode.json, parse them into structured rules,',
|
|
38
|
-
'format them into human-readable rules, and write the formatted rules back to the original files.',
|
|
39
|
-
'Accepts an optional mode: verbose (full Rule/Reason pairs),',
|
|
40
|
-
'balanced (LLM decides which rules need reasons), or concise (bullet list, no reasons).',
|
|
41
|
-
'Defaults to balanced.',
|
|
42
|
-
'Accepts an optional files parameter to process specific files instead of running discovery.',
|
|
43
|
-
].join(' '),
|
|
44
|
-
args: {
|
|
45
|
-
mode: tool.schema.string().optional().describe('Output format: verbose, balanced, or concise (default: balanced)'),
|
|
46
|
-
files: tool.schema.string().optional().describe('Comma-separated file paths to process instead of discovering from opencode.json'),
|
|
47
|
-
},
|
|
48
|
-
async execute(args, context) {
|
|
49
|
-
// validate mode argument
|
|
50
|
-
const mode = isFormatMode(args.mode) ? args.mode : 'balanced';
|
|
51
|
-
try {
|
|
52
|
-
// resolve files: explicit paths or discovery
|
|
53
|
-
const resolved = await resolveFiles(directory, args.files);
|
|
54
|
-
if (resolved.error !== null) {
|
|
55
|
-
return resolved.error;
|
|
56
|
-
}
|
|
57
|
-
// detect model from current session
|
|
58
|
-
const model = await detectModel(client, context.sessionID);
|
|
59
|
-
if (!model) {
|
|
60
|
-
return 'Could not detect current model. Send a message first, then call irf-rewrite.';
|
|
61
|
-
}
|
|
62
|
-
// create a session for internal LLM calls
|
|
63
|
-
const sessionResult = await client.session.create({ body: { title: 'IRF Parse' } });
|
|
64
|
-
if (!sessionResult.data) {
|
|
65
|
-
return 'Failed to create internal session';
|
|
66
|
-
}
|
|
67
|
-
const sessionId = sessionResult.data.id;
|
|
68
|
-
// close over session details so processFile only needs a prompt callback
|
|
69
|
-
const prompt = (text, schema) => (promptWithRetry({
|
|
70
|
-
client,
|
|
71
|
-
sessionId,
|
|
72
|
-
initialPrompt: text,
|
|
73
|
-
schema,
|
|
74
|
-
model,
|
|
75
|
-
}));
|
|
76
|
-
// process files sequentially; parallel prompting through a shared
|
|
77
|
-
// session may cause ordering issues depending on SDK behavior
|
|
78
|
-
const fileResults = [];
|
|
79
|
-
for (const file of resolved.data) {
|
|
80
|
-
// bail if the tool call was cancelled
|
|
81
|
-
if (context.abort.aborted) {
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
fileResults.push(await processFile({ file, prompt, mode }));
|
|
85
|
-
}
|
|
86
|
-
// clean up the internal session
|
|
87
|
-
await safeAsync(() => client.session.delete({ path: { id: sessionId } }));
|
|
88
|
-
const table = buildTable(fileResults.map(toTableRow));
|
|
89
|
-
if (table.length > 0) {
|
|
90
|
-
await sendResult({
|
|
91
|
-
client,
|
|
92
|
-
sessionID: context.sessionID,
|
|
93
|
-
text: table,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return table;
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
100
|
-
return 'irf-rewrite error: ' + msg;
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
}),
|
|
104
|
-
'irf-add': tool({
|
|
105
|
-
description: [
|
|
106
|
-
'Parse unstructured input into structured rules, format them,',
|
|
107
|
-
'and append to the end of an instruction file without rewriting existing content.',
|
|
108
|
-
'Accepts an optional mode: verbose (full Rule/Reason pairs),',
|
|
109
|
-
'balanced (LLM decides which rules need reasons), or concise (bullet list, no reasons).',
|
|
110
|
-
'Defaults to balanced.',
|
|
111
|
-
'Accepts an optional file parameter to specify the target file.',
|
|
112
|
-
'If no file is specified, appends to the first discovered instruction file.',
|
|
113
|
-
].join(' '),
|
|
114
|
-
args: {
|
|
115
|
-
input: tool.schema.string().describe('Unstructured text describing the rule(s) to add'),
|
|
116
|
-
file: tool.schema.string().optional().describe('File path to append to. If omitted, uses the first discovered instruction file.'),
|
|
117
|
-
mode: tool.schema.string().optional().describe('Output format: verbose, balanced, or concise (default: balanced)'),
|
|
118
|
-
},
|
|
119
|
-
async execute(args, context) {
|
|
120
|
-
const mode = isFormatMode(args.mode) ? args.mode : 'balanced';
|
|
121
|
-
try {
|
|
122
|
-
// resolve target file path
|
|
123
|
-
let filePath = args.file;
|
|
124
|
-
if (!filePath) {
|
|
125
|
-
const resolved = await resolveFiles(directory);
|
|
126
|
-
if (resolved.error !== null) {
|
|
127
|
-
return resolved.error;
|
|
128
|
-
}
|
|
129
|
-
const first = resolved.data[0];
|
|
130
|
-
if (!first) {
|
|
131
|
-
return 'No instruction files found in opencode.json';
|
|
132
|
-
}
|
|
133
|
-
filePath = first.path;
|
|
134
|
-
}
|
|
135
|
-
// detect model from current session
|
|
136
|
-
const model = await detectModel(client, context.sessionID);
|
|
137
|
-
if (!model) {
|
|
138
|
-
return 'Could not detect current model. Send a message first, then call irf-add.';
|
|
139
|
-
}
|
|
140
|
-
// create a session for internal LLM calls
|
|
141
|
-
const sessionResult = await client.session.create({ body: { title: 'IRF Add' } });
|
|
142
|
-
if (!sessionResult.data) {
|
|
143
|
-
return 'Failed to create internal session';
|
|
144
|
-
}
|
|
145
|
-
const sessionId = sessionResult.data.id;
|
|
146
|
-
const prompt = (text, schema) => (promptWithRetry({
|
|
147
|
-
client,
|
|
148
|
-
sessionId,
|
|
149
|
-
initialPrompt: text,
|
|
150
|
-
schema,
|
|
151
|
-
model,
|
|
152
|
-
}));
|
|
153
|
-
const result = await appendRules({
|
|
154
|
-
input: args.input,
|
|
155
|
-
filePath,
|
|
156
|
-
directory,
|
|
157
|
-
prompt,
|
|
158
|
-
mode,
|
|
159
|
-
});
|
|
160
|
-
// clean up the internal session
|
|
161
|
-
await safeAsync(() => client.session.delete({ path: { id: sessionId } }));
|
|
162
|
-
if (result.status !== 'success') {
|
|
163
|
-
return result.status + ': ' + result.error;
|
|
164
|
-
}
|
|
165
|
-
const msg = 'Added ' + result.rulesCount + ' rule(s) to ' + result.path;
|
|
166
|
-
await sendResult({
|
|
167
|
-
client,
|
|
168
|
-
sessionID: context.sessionID,
|
|
169
|
-
text: msg,
|
|
170
|
-
});
|
|
171
|
-
return msg;
|
|
172
|
-
}
|
|
173
|
-
catch (err) {
|
|
174
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
175
|
-
return 'irf-add error: ' + msg;
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
}),
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
export default plugin;
|
|
183
|
-
//# sourceMappingURL=irf.js.map
|
package/dist/irf.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"irf.js","sourceRoot":"","sources":["../irf.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,E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