pstack-opencode 0.15.36-opencode → 0.15.37-opencode

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pstack-opencode",
3
- "version": "0.15.36-opencode",
3
+ "version": "0.15.37-opencode",
4
4
  "description": "pstack for OpenCode.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/plugin/index.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  isSkillEvent,
17
17
  modeEntry,
18
18
  modelsEntry,
19
+ readAgents,
19
20
  readSkills,
20
21
  withEvent,
21
22
  } from "./lib.js"
@@ -28,6 +29,7 @@ export default {
28
29
  id: "pstack",
29
30
  async setup(ctx) {
30
31
  const skills = readSkills(join(ROOT, "skills"))
32
+ const agents = readAgents(join(ROOT, "agents"))
31
33
  const configDir = join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "opencode")
32
34
  const modelsFile = ctx.options?.modelsFile ?? join(configDir, "pstack-models.md")
33
35
 
@@ -128,6 +130,18 @@ export default {
128
130
  }
129
131
  })
130
132
 
133
+ await ctx.agent.transform((editor) => {
134
+ for (const agent of agents) {
135
+ if (editor.get(agent.id)) continue
136
+ editor.update(agent.id, (draft) => {
137
+ draft.description = agent.description
138
+ draft.mode = agent.mode
139
+ if (agent.color) draft.color = agent.color
140
+ if (agent.system) draft.system = agent.system
141
+ })
142
+ }
143
+ })
144
+
131
145
  await ctx.session.hook(
132
146
  "prompt",
133
147
  guarded("prompt", async (event) => {
package/plugin/lib.js CHANGED
@@ -129,6 +129,27 @@ export function readSkills(skillsDir) {
129
129
  return [...skills, ...readPlaybooks(join(skillsDir, MODE_AGENT)).filter((playbook) => !ids.has(playbook.id))]
130
130
  }
131
131
 
132
+ const AGENT_MODES = ["primary", "subagent", "all"]
133
+
134
+ export function readAgents(agentsDir) {
135
+ return readdirSync(agentsDir)
136
+ .filter((name) => name.endsWith(".md"))
137
+ .sort()
138
+ .map((name) => {
139
+ const path = join(agentsDir, name)
140
+ const { data, body } = parseFrontmatter(readFileSync(path, "utf8"))
141
+ if (!data.description) throw new Error(`pstack: ${path} has no description`)
142
+ if (!AGENT_MODES.includes(data.mode)) throw new Error(`pstack: ${path} has mode ${JSON.stringify(data.mode)}, expected one of ${AGENT_MODES.join(", ")}`)
143
+ return {
144
+ id: name.slice(0, -".md".length),
145
+ description: data.description,
146
+ mode: data.mode,
147
+ ...(data.color ? { color: data.color } : {}),
148
+ ...(body ? { system: body } : {}),
149
+ }
150
+ })
151
+ }
152
+
132
153
  export function commandDescription(description, max = 120) {
133
154
  const sentence = description.match(/^.*?[.!?](?=\s|$)/)?.[0] ?? description
134
155
  if (sentence.length <= max) return sentence
@@ -10,7 +10,7 @@ Answer the user's question about pstack, hand them a prompt they can send, and l
10
10
 
11
11
  A message that asks for work, such as "use pstack to fix this bug", is not a help question. Read [`poteto-mode`](../poteto-mode/SKILL.md), do the work under it, and mention once that the `poteto-mode` agent keeps it on.
12
12
 
13
- This file maps questions to the skills and guide pages that hold the answers. Those files own the details. Read the file you route to before you quote it, and trust it when it disagrees with this map. The plugin turns the links here into absolute paths in its folder, which the installer links from the user's checkout of this repo, so give the user that absolute path.
13
+ This file maps questions to the skills and guide pages that hold the answers. Those files own the details. Read the file you route to before you quote it, and trust it when it disagrees with this map. The plugin turns the links here into absolute paths in its folder, which is either the installed `pstack-opencode` package or the user's checkout of this repo that the installer linked, so give the user that absolute path.
14
14
 
15
15
  ## Find out what they need
16
16
 
@@ -35,7 +35,7 @@ When the models file is missing and it matters, ask whether the user wants to pi
35
35
 
36
36
  ## Get set up
37
37
 
38
- 1. From a checkout of this repo, run `npm run install-pstack`. It links `src/` into `~/.config/opencode`, or into one project's `.opencode/` with `npm run install-pstack -- --project <dir>`, and copies nothing. Add the `experimental` settings it recommends: `"todo": true` gives agents `todowrite`, and `"subagent_depth": 2` lets a delegate run skills that spawn their own subagents.
38
+ 1. Add `"plugins": ["pstack-opencode"]` to `~/.config/opencode/opencode.jsonc`. The plugin registers every skill, its slash command, and the three agents. To run from a checkout of this repo instead, run `npm run install-pstack` there. It links `src/` into `~/.config/opencode`, or into one project's `.opencode/` with `npm run install-pstack -- --project <dir>`, and copies nothing. Either way, add two `experimental` settings, which the installer prints when they are missing: `"todo": true` gives agents `todowrite`, and `"subagent_depth": 2` lets a delegate run skills that spawn their own subagents.
39
39
  2. Run [`/setup-pstack`](../setup-pstack/SKILL.md). It asks for a reasoning budget, maps a model to each role, and writes `~/.config/opencode/pstack-models.md`. The plugin reads that file at the next request, so no restart is needed. Then it offers once each to generate a verification skill and a formal verification skill for the project, unless the project already has one.
40
40
  3. Start a real task with `/poteto-mode`, a goal, and a check that can pass or fail.
41
41
 
@@ -50,10 +50,12 @@ If cost is the worry, say where the tokens go and how to spend fewer. pstack spe
50
50
  Either way of starting it keeps the mode on:
51
51
 
52
52
  - `/poteto-mode` attaches the skill to its message and keeps a `pstack-mode` instruction entry on that session for the rest of the session, whatever agent it runs under.
53
- - The `poteto-mode` agent attaches the skill to the first message and keeps the same entry until the user switches agents. Press Tab to select it, or start with `opencode --agent poteto-mode`.
53
+ - The `poteto-mode` agent attaches the skill to the first message and keeps the same entry until the user switches agents. Press Tab to select it, or start with `opencode --agent poteto-mode`. Both work with the package and with the installer, and neither needs a file in `agents/`.
54
54
 
55
55
  The entry keeps the mode in context every turn and through compaction.
56
56
 
57
+ A user file in `agents/` named after a pstack agent, such as `poteto-mode.md`, overrides the fields it sets, and pstack's definition fills in the rest.
58
+
57
59
  Mid-chat, "new task" makes the mode match a fresh playbook. `/poteto-mode` already uses `poteto-agent` for the subagents its playbook steps spawn. To get the same style from a subagent of your own, spawn it with `agent: "poteto-agent"`.
58
60
 
59
61
  ## Pick a skill