golden-hoop-spell-opencode 0.1.0 → 0.1.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 CHANGED
@@ -147,6 +147,23 @@ codegraph 是本插件的上下文提取后端,提供符号级代码图谱(c
147
147
 
148
148
  > `ghs-code` 的编码子代理同样由 Task tool 派发,但它是临时的(由 `ghs-code` 返回的 feature-impl 提示即时构造),不是随包发布的固定模板,故不在本表。
149
149
 
150
+ ## Slash Commands(8 个 `/ghs-*` 命令)
151
+
152
+ 插件安装后,8 个 `/ghs-*` 斜杠命令在**首次启动时自动注册**——通过 Plugin 的 `config` hook 注入 `cfg.command`,无需手动创建 `.md` 文件或额外重启。
153
+
154
+ | 命令 | 用法 | 说明 |
155
+ |---|---|---|
156
+ | `/ghs-init` | `/ghs-init <项目名>` | 初始化 ghs 追踪文件 |
157
+ | `/ghs-config` | `/ghs-config` | 重新生成子代理 markdown |
158
+ | `/ghs-plan-start` | `/ghs-plan-start` | 启动计划生成流程 |
159
+ | `/ghs-sprint` | `/ghs-sprint "<名称>" "<目标>"` | 创建新 sprint |
160
+ | `/ghs-code` | `/ghs-code [feature_id] [--parallel]` | 派发 feature 实现 |
161
+ | `/ghs-status` | `/ghs-status` | 查看项目状态 |
162
+ | `/ghs-archive` | `/ghs-archive [--dry-run\|--list]` | 归档已完成 sprint |
163
+ | `/ghs-force-archive` | `/ghs-force-archive <nonce>` | 强制归档所有 sprint |
164
+
165
+ > 内部 dispatcher 工具 `ghs-plan-review` 和 `ghs-plan-finalize` 不提供斜杠命令——它们由 plan 工作流自动衔接,不直接面向用户。
166
+
150
167
  ## 工作流
151
168
 
152
169
  OpenCode 会话中的主 AI 驱动每一次状态转移,**通过 Task tool 派发隔离子代理完成 LLM 工作**。完整顺序:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "golden-hoop-spell-opencode",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "main": "src/index.ts",
5
5
  "devDependencies": {
6
6
  "@opencode-ai/plugin": "1.4.3",
@@ -0,0 +1,101 @@
1
+ // Slash command definitions for the ghs-* workflow tools.
2
+ //
3
+ // These are injected into the OpenCode Config object's `command` field via
4
+ // the plugin's `config` hook (see src/plugin.ts). OpenCode reads
5
+ // `cfg.command` when the TUI requests `GET /command`, so the commands are
6
+ // available on the very first startup — no file writes or restart needed.
7
+ //
8
+ // Each entry conforms to the OpenCode Command shape:
9
+ // - `template`: The prompt sent to the LLM when the user types the command.
10
+ // Supports `$ARGUMENTS`, `$1`, `$2`, … for argument passing.
11
+ // - `description`: Shown in the TUI command palette.
12
+ //
13
+ // Commands map 1:1 to the 8 user-facing ghs-* tools. The two internal
14
+ // dispatcher tools (ghs-plan-review, ghs-plan-finalize) are intentionally
15
+ // excluded — they consume raw delimited subagent output and are never
16
+ // invoked directly by the user.
17
+
18
+ /**
19
+ * A single slash command definition matching OpenCode's Config.command shape.
20
+ */
21
+ export interface GhCommand {
22
+ template: string;
23
+ description: string;
24
+ }
25
+
26
+ /**
27
+ * The 8 user-facing `/ghs-*` slash commands, keyed by command name.
28
+ *
29
+ * Injected into `cfg.command` by the plugin's `config` hook. When the user
30
+ * types `/ghs-status` (etc.) in the TUI, OpenCode sends the corresponding
31
+ * `template` string to the LLM, which then calls the matching tool.
32
+ *
33
+ * Argument-passing commands use OpenCode's built-in placeholders:
34
+ * - `$ARGUMENTS` — the entire argument string
35
+ * - `$1`, `$2`, … — positional arguments
36
+ */
37
+ export const GHS_COMMANDS: Record<string, GhCommand> = {
38
+ "ghs-init": {
39
+ description: "初始化 ghs 追踪文件(.ghs/ + .opencode/agents/)",
40
+ template:
41
+ 'Call the `ghs-init` tool to initialise the Golden Hoop Spell tracking files for this project.\n\n' +
42
+ 'Arguments: $ARGUMENTS\n\n' +
43
+ "If arguments are provided, use the first argument as `project_name`. " +
44
+ "If `--description` is followed by a quoted string, pass it as `description`. " +
45
+ "If `--force` is present, set `force: true`. " +
46
+ "If no project name is given, ask the user for one before calling the tool.",
47
+ },
48
+ "ghs-config": {
49
+ description: "重新生成 ghs 子代理 markdown(编辑 .ghs/ghs.json 后调用)",
50
+ template:
51
+ "Call the `ghs-config` tool to regenerate the ghs subagent markdown files " +
52
+ "from the current `.ghs/ghs.json` config.\n\n" +
53
+ "If `--dry-run` is present in the arguments, pass `dry_run: true`.",
54
+ },
55
+ "ghs-plan-start": {
56
+ description: "启动 ghs 计划生成流程(上下文快照 → 计划设计 → 评审)",
57
+ template:
58
+ "Call the `ghs-plan-start` tool to start a new Golden Hoop Spell " +
59
+ "plan-generation loop.",
60
+ },
61
+ "ghs-sprint": {
62
+ description: "创建新的 ghs sprint(分解为原子 feature)",
63
+ template:
64
+ "Call the `ghs-sprint` tool to create a new sprint skeleton in features.json.\n\n" +
65
+ "Arguments: $ARGUMENTS\n\n" +
66
+ "Parse the arguments as: the first quoted string as `sprint_name`, " +
67
+ "and the remainder (or second quoted string) as `goal`. " +
68
+ "If either is missing, ask the user for the missing value(s) before calling the tool.",
69
+ },
70
+ "ghs-code": {
71
+ description: "派发 ghs feature 实现(单个或并行批次)",
72
+ template:
73
+ "Call the `ghs-code` tool to dispatch feature implementation.\n\n" +
74
+ "Arguments: $ARGUMENTS\n\n" +
75
+ "If a feature ID (e.g. `s5-feat-003`) is provided, pass it as `feature_id`. " +
76
+ "If `--parallel` is present, set `parallel: true`. " +
77
+ "If no arguments are given, call without `feature_id` to get the next ready feature.",
78
+ },
79
+ "ghs-status": {
80
+ description: "显示 ghs 项目状态(sprint/feature 进度)",
81
+ template:
82
+ "Call the `ghs-status` tool to display the current Golden Hoop Spell project status.",
83
+ },
84
+ "ghs-archive": {
85
+ description: "归档已完成的 ghs sprint",
86
+ template:
87
+ "Call the `ghs-archive` tool to archive completed sprints.\n\n" +
88
+ "Arguments: $ARGUMENTS\n\n" +
89
+ "If `--dry-run` is present, pass `dry_run: true` for a preview. " +
90
+ "If `--list` is present, pass `list: true` to list without archiving.",
91
+ },
92
+ "ghs-force-archive": {
93
+ description: "强制归档所有 ghs sprint(含未完成的)",
94
+ template:
95
+ "Call the `ghs-force-archive` tool to force-archive all sprints regardless of status.\n\n" +
96
+ "This requires a `transcription` nonce token — call `ghs-archive` first " +
97
+ "to obtain one, then pass it here.\n\n" +
98
+ "Arguments: $ARGUMENTS\n\n" +
99
+ "Use the first argument as the `transcription` value.",
100
+ },
101
+ };
package/src/plugin.ts CHANGED
@@ -7,6 +7,14 @@
7
7
  // ghs-status / ghs-archive / ghs-force-archive) under their hyphenated
8
8
  // keys — the complete plan §3.4 D2 tool surface (Phase 0 spike 001
9
9
  // confirmed hyphenated keys load + round-trip correctly).
10
+ // - Injects 8 `/ghs-*` slash commands into the OpenCode Config via the
11
+ // `config` hook. Source analysis of OpenCode's plugin/index.ts +
12
+ // config/config.ts + command/index.ts confirmed that the `config` hook
13
+ // receives the same mutable Config object reference that the Command
14
+ // service later reads via `config.get()`. The hook runs during plugin
15
+ // initialization (before the HTTP server accepts requests), so the
16
+ // injected commands are available on the very first startup — no file
17
+ // writes or restart needed.
10
18
  // - Pushes a single-line workflow hint into the AI's system prompt via the
11
19
  // `experimental.chat.system.transform` hook (Phase 0 spike 001 confirmed
12
20
  // strings pushed here land in the system prompt verbatim).
@@ -29,6 +37,7 @@ import { planStartTool } from "./tools/plan-start.ts";
29
37
  import { planReviewTool } from "./tools/plan-review.ts";
30
38
  import { planFinalizeTool } from "./tools/plan-finalize.ts";
31
39
  import { codeTool } from "./tools/code.ts";
40
+ import { GHS_COMMANDS } from "./lib/commands.ts";
32
41
 
33
42
  /**
34
43
  * Single-line hint pushed into the AI's system prompt on every chat. Lists
@@ -47,7 +56,8 @@ const SYSTEM_HINT_TEXT =
47
56
  "Golden Hoop Spell (ghs) plugin — orchestrates a structured init → plan → sprint → code → status → archive workflow. " +
48
57
  "Tools implemented: ghs-init, ghs-config, ghs-plan-start, ghs-plan-review, ghs-plan-finalize, ghs-sprint, ghs-code, ghs-status, ghs-archive, ghs-force-archive. " +
49
58
  "Workflow order: ghs-init → ghs-config → ghs-plan-start → ghs-plan-review → ghs-plan-finalize → ghs-sprint → ghs-code → ghs-status → ghs-archive. " +
50
- "Model IDs for the 3 plan-dispatcher subagents are user-configurable via `.ghs/ghs.json`; after editing run `ghs-config` then restart OpenCode.";
59
+ "Model IDs for the 3 plan-dispatcher subagents are user-configurable via `.ghs/ghs.json`; after editing run `ghs-config` then restart OpenCode. " +
60
+ "Slash commands /ghs-init, /ghs-config, /ghs-plan-start, /ghs-sprint, /ghs-code, /ghs-status, /ghs-archive, /ghs-force-archive are auto-registered on startup.";
51
61
 
52
62
  /**
53
63
  * The ghs OpenCode plugin. Default-exported from `src/index.ts`.
@@ -70,6 +80,10 @@ export const ghsPlugin: Plugin = async () => ({
70
80
  "ghs-archive": archiveTool,
71
81
  "ghs-force-archive": forceArchiveTool,
72
82
  },
83
+ config: async (cfg) => {
84
+ cfg.command ??= {};
85
+ Object.assign(cfg.command, GHS_COMMANDS);
86
+ },
73
87
  "experimental.chat.system.transform": async (_input, output) => {
74
88
  output.system.push(SYSTEM_HINT_TEXT);
75
89
  },