opencode-sat 0.0.16-next.3 → 0.0.17
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 +5 -205
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,213 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# opencode-sat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package has been renamed to [opencode-speech-act-theory](https://www.npmjs.com/package/opencode-speech-act-theory).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Quick Start
|
|
8
|
-
|
|
9
|
-
Add the plugin to your `opencode.json` and restart OpenCode:
|
|
5
|
+
Install the new package:
|
|
10
6
|
|
|
11
7
|
```json
|
|
12
8
|
{
|
|
13
|
-
"plugin": ["opencode-
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Then just tell OpenCode what you want:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
Rewrite my instruction files
|
|
21
|
-
Add a rule about using early returns
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Messy or voice-transcribed input can be restructured into a clear task hierarchy using the prompt tools.
|
|
25
|
-
|
|
26
|
-
## Tools
|
|
27
|
-
|
|
28
|
-
For the theory behind the plugin, see [Theoretical Foundation](#theoretical-foundation).
|
|
29
|
-
|
|
30
|
-
The plugin provides 7 tools organized into two pipelines.
|
|
31
|
-
|
|
32
|
-
### Rules Pipeline
|
|
33
|
-
|
|
34
|
-
Discovers, parses, formats, and writes instruction rules. The LLM drives each step.
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
discover-rules -> parse-rules -> format-rules -> rewrite-rules
|
|
38
|
-
-> add-rules
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
#### discover-rules
|
|
42
|
-
|
|
43
|
-
Reads instruction files from your `opencode.json` configuration. Accepts an optional `files` string of comma-separated paths to read specific files instead of running discovery.
|
|
44
|
-
|
|
45
|
-
#### parse-rules
|
|
46
|
-
|
|
47
|
-
Parses instruction file content or unstructured user input into structured rules JSON. Validates the parsed rules against the schema and returns validated JSON. Call after `discover-rules` and before `format-rules`.
|
|
48
|
-
|
|
49
|
-
#### format-rules
|
|
50
|
-
|
|
51
|
-
Converts parsed rules into human-readable formatted rule strings. Accepts an optional `mode` (`verbose`, `balanced`, or `concise`, default `balanced`). Validates the formatted rules and returns validated JSON. Call after `parse-rules` and before `rewrite-rules` or `add-rules`.
|
|
52
|
-
|
|
53
|
-
#### rewrite-rules
|
|
54
|
-
|
|
55
|
-
Writes formatted rule strings to instruction files, replacing existing content. Accepts an optional `mode` and an optional `files` string of comma-separated paths. Call after `format-rules`.
|
|
56
|
-
|
|
57
|
-
#### add-rules
|
|
58
|
-
|
|
59
|
-
Appends formatted rule strings to an instruction file without rewriting existing content. Accepts an optional `mode` and an optional `file` path (defaults to the first discovered instruction file). Call after `format-rules`.
|
|
60
|
-
|
|
61
|
-
### Formatting Modes
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
rewrite-rules [mode=concise]
|
|
65
|
-
rewrite-rules [files=a.md,b.md, mode=verbose]
|
|
66
|
-
add-rules [mode=concise]
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**Input:**
|
|
70
|
-
```
|
|
71
|
-
Always use return await when returning promises from async functions. This provides
|
|
72
|
-
better stack traces and error handling. Arrow functions are the standard function
|
|
73
|
-
syntax. Do not use function declarations or function expressions because arrow
|
|
74
|
-
functions provide lexical this binding and a more compact syntax.
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**verbose** - Full Rule/Reason pairs for every rule.
|
|
78
|
-
```
|
|
79
|
-
Rule: Use return await when returning promises from async functions.
|
|
80
|
-
Reason: Provides better stack traces and error handling.
|
|
81
|
-
|
|
82
|
-
Rule: Use arrow functions as the standard function syntax.
|
|
83
|
-
Reason: Arrow functions provide lexical this binding and a more compact syntax.
|
|
84
|
-
|
|
85
|
-
Rule: Do not use function declarations or function expressions.
|
|
86
|
-
Reason: Arrow functions are the standard syntax for the project.
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**balanced** (default) - The LLM decides which rules need reasons.
|
|
90
|
-
```
|
|
91
|
-
Rule: Use return await when returning promises from async functions.
|
|
92
|
-
Reason: Provides better stack traces and error handling.
|
|
93
|
-
|
|
94
|
-
Rule: Use arrow functions as the standard function syntax.
|
|
95
|
-
|
|
96
|
-
Rule: Do not use function declarations or function expressions.
|
|
97
|
-
Reason: Arrow functions provide lexical this binding and a more compact syntax.
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**concise** - Bullet list of directives only, no reasons.
|
|
101
|
-
```
|
|
102
|
-
- Use return await when returning promises from async functions.
|
|
103
|
-
- Use arrow functions as the standard function syntax.
|
|
104
|
-
- Do not use function declarations or function expressions.
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Prompt Pipeline
|
|
108
|
-
|
|
109
|
-
Restructures messy or unstructured user input into a clear task hierarchy.
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
parse-prompt -> format-prompt
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
#### parse-prompt
|
|
116
|
-
|
|
117
|
-
Decomposes raw text (often from voice transcription) into structured tasks with intent, targets, constraints, context, and recursive subtasks. Validates against the schema and returns validated JSON.
|
|
118
|
-
|
|
119
|
-
#### format-prompt
|
|
120
|
-
|
|
121
|
-
Renders validated tasks from `parse-prompt` into a formatted markdown tree view.
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
parse-prompt [input=refactor the search module add guards to each provider make sure bsky and wiki get validated then run the tests]
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Output:
|
|
128
|
-
```
|
|
129
|
-
┌ 1. Refactor the search module
|
|
130
|
-
│ > Targets: src/search.ts, src/providers/
|
|
131
|
-
│ > Constraints: use safeAsync, no optional chaining
|
|
132
|
-
│ > Context: Current error handling is inconsistent
|
|
133
|
-
│
|
|
134
|
-
├──┬ 2. Add guards to providers
|
|
135
|
-
│ │ > Targets: src/providers/
|
|
136
|
-
│ │ > Constraints: use isRecord helper
|
|
137
|
-
│ │
|
|
138
|
-
│ ├─── 3. Validate bsky responses
|
|
139
|
-
│ │ > Targets: bsky-search.ts
|
|
140
|
-
│ │
|
|
141
|
-
│ └─── 4. Validate wiki responses
|
|
142
|
-
│ > Targets: wiki-search.ts
|
|
143
|
-
│
|
|
144
|
-
├─── 5. Update error handling
|
|
145
|
-
│ > Targets: src/utils/safe.ts
|
|
146
|
-
│
|
|
147
|
-
└─── 6. Run the tests
|
|
148
|
-
> Constraints: fix any failures
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## Theoretical Foundation
|
|
152
|
-
|
|
153
|
-
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.
|
|
154
|
-
|
|
155
|
-
### Rule Formatting (deontic logic, regulative directives)
|
|
156
|
-
|
|
157
|
-
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.
|
|
158
|
-
|
|
159
|
-
The plugin parses unstructured rule text into structured components:
|
|
160
|
-
|
|
161
|
-
```ts
|
|
162
|
-
type ParsedRule = {
|
|
163
|
-
strength: 'obligatory' | 'forbidden' | 'permissible' | 'optional' | 'supererogatory' | 'indifferent' | 'omissible'
|
|
164
|
-
action: string
|
|
165
|
-
target: string
|
|
166
|
-
context?: string
|
|
167
|
-
reason: string
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
The `strength` field maps to deontic operators. The critical relationship is F(A) = O(not-A): a forbidden action must be negated in expression.
|
|
172
|
-
|
|
173
|
-
| Strength | Operator | Expression |
|
|
174
|
-
|---|---|---|
|
|
175
|
-
| obligatory | O(A) | positive imperative: "use consistent whitespace" |
|
|
176
|
-
| forbidden | F(A) = O(not-A) | negate with "do not": "do not use non-null assertions" |
|
|
177
|
-
| permissible | P(A) | prefix with "may": "may use type assertions when necessary" |
|
|
178
|
-
| optional | P(A) and P(not-A) | prefix with "may choose to": "may choose to add commit body" |
|
|
179
|
-
| supererogatory | beyond O(A) | prefix with "ideally": "ideally provide comprehensive documentation" |
|
|
180
|
-
| indifferent | P(A) and P(not-A) | prefix with "either way is fine": "either way is fine for naming style" |
|
|
181
|
-
| omissible | P(not-A) | prefix with "may omit": "may omit post-task explanations" |
|
|
182
|
-
|
|
183
|
-
### Prompt Formatting (action/planning logic, performative directives)
|
|
184
|
-
|
|
185
|
-
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.
|
|
186
|
-
|
|
187
|
-
A messy user prompt typically mixes three levels together:
|
|
188
|
-
|
|
189
|
-
- **Goal** (desired end state): "I want search results to show up in chat"
|
|
190
|
-
- **Tasks** (what to do): "add a postResult call, update the providers"
|
|
191
|
-
- **Constraints** (conditions/preferences): "don't break existing tests, use safeAsync"
|
|
192
|
-
|
|
193
|
-
The plugin parses raw input into structured components:
|
|
194
|
-
|
|
195
|
-
```ts
|
|
196
|
-
type ParsedTask = {
|
|
197
|
-
intent: string
|
|
198
|
-
targets: Array<string>
|
|
199
|
-
constraints: Array<string>
|
|
200
|
-
context?: string
|
|
201
|
-
subtasks: Array<ParsedTask>
|
|
9
|
+
"plugin": ["opencode-speech-act-theory"]
|
|
202
10
|
}
|
|
203
11
|
```
|
|
204
12
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
## Disclaimer
|
|
208
|
-
|
|
209
|
-
I'm not an NLP expert. I stumbled onto speech act theory and deontic logic while researching NLP and thought it could be a good fit for structuring instructions. The implementation may not perfectly align with academic definitions, but the goal is practical utility.
|
|
210
|
-
|
|
211
|
-
## License
|
|
212
|
-
|
|
213
|
-
MIT
|
|
13
|
+
[opencode-speech-act-theory on npm](https://www.npmjs.com/package/opencode-speech-act-theory)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-sat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
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",
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"speech-act-theory",
|
|
13
13
|
"deontic-logic"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.com/whaaaley/opencode-
|
|
15
|
+
"homepage": "https://github.com/whaaaley/opencode-speech-act-theory#readme",
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/whaaaley/opencode-
|
|
17
|
+
"url": "https://github.com/whaaaley/opencode-speech-act-theory/issues"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/whaaaley/opencode-
|
|
21
|
+
"url": "git+https://github.com/whaaaley/opencode-speech-act-theory.git"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"author": "Dustin Dowell",
|