@kisev/skills-opencode 1.1.1 → 2.0.0

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.
Files changed (157) hide show
  1. package/README.md +134 -108
  2. package/README.ru.md +242 -0
  3. package/dist/agent-profiles.d.ts +1 -1
  4. package/dist/agent-profiles.js +21 -10
  5. package/dist/assets/agents/architect.md +67 -0
  6. package/{assets → dist/assets}/agents/critic.md +17 -2
  7. package/dist/assets/agents/manager.md +36 -0
  8. package/{assets → dist/assets}/agents/mapper.md +2 -2
  9. package/dist/assets/agents/review.md +25 -0
  10. package/{assets → dist/assets}/agents/worker.md +7 -5
  11. package/dist/assets/commands/agent-profiles.md +9 -0
  12. package/dist/assets/commands/agents-md.md +10 -0
  13. package/dist/assets/commands/askme.md +10 -0
  14. package/dist/assets/commands/ast-grep.md +10 -0
  15. package/dist/assets/commands/capabilities.md +9 -0
  16. package/dist/assets/commands/code-explain.md +10 -0
  17. package/dist/assets/commands/code-review.md +10 -0
  18. package/dist/assets/commands/commit-msg.md +10 -0
  19. package/dist/assets/commands/docs-prepare.md +10 -0
  20. package/dist/assets/commands/docs-review.md +10 -0
  21. package/dist/assets/commands/doctor.md +9 -0
  22. package/dist/assets/commands/doit.md +10 -0
  23. package/dist/assets/commands/goal.md +10 -0
  24. package/dist/assets/commands/humanize.md +10 -0
  25. package/dist/assets/commands/lsp-report.md +10 -0
  26. package/dist/assets/commands/mattermost.md +10 -0
  27. package/dist/assets/commands/mr-prepare.md +10 -0
  28. package/dist/assets/commands/reconcile.md +9 -0
  29. package/dist/assets/commands/release-prepare.md +10 -0
  30. package/dist/assets/commands/release-review.md +10 -0
  31. package/dist/assets/commands/rtk.md +10 -0
  32. package/dist/assets/commands/skill-improve.md +10 -0
  33. package/dist/assets/commands/slides-prompts-prepare.md +10 -0
  34. package/dist/assets/commands/spec-manage.md +10 -0
  35. package/dist/assets/commands/stopit.md +10 -0
  36. package/dist/assets/commands/summary.md +10 -0
  37. package/dist/assets/commands/task-prepare.md +10 -0
  38. package/dist/assets/commands/task-review.md +10 -0
  39. package/dist/assets/commands/task-triage.md +10 -0
  40. package/dist/assets/commands/team-retro.md +10 -0
  41. package/dist/assets/commands/team-roadmap.md +10 -0
  42. package/dist/assets/commands/team-sprint-close.md +10 -0
  43. package/dist/assets/commands/team-sprint-start.md +10 -0
  44. package/dist/assets/lsp-catalog.json +30 -0
  45. package/dist/assets/migration-inventory.json +294 -0
  46. package/dist/catalog.d.ts +8 -0
  47. package/dist/catalog.js +38 -0
  48. package/dist/cli-output.d.ts +7 -0
  49. package/dist/cli-output.js +68 -1
  50. package/dist/cli.js +256 -59
  51. package/dist/contracts.d.ts +52 -0
  52. package/dist/contracts.js +98 -0
  53. package/dist/doctor.d.ts +44 -0
  54. package/dist/doctor.js +595 -0
  55. package/dist/generate-assets.js +17 -2
  56. package/dist/index.d.ts +84 -55
  57. package/dist/index.js +170 -37
  58. package/dist/installer.d.ts +33 -5
  59. package/dist/installer.js +252 -28
  60. package/dist/lifecycle.d.ts +3 -0
  61. package/dist/lifecycle.js +49 -17
  62. package/dist/plugins/rtk.js +4 -1
  63. package/dist/reconcile.d.ts +43 -0
  64. package/dist/reconcile.js +507 -0
  65. package/dist/registry.d.ts +7 -4
  66. package/dist/registry.js +28 -88
  67. package/dist/routing.d.ts +97 -3
  68. package/dist/routing.js +470 -18
  69. package/dist/runtime/state.d.ts +1 -0
  70. package/dist/runtime/state.js +12 -5
  71. package/dist/runtime/worktree.d.ts +33 -0
  72. package/dist/runtime/worktree.js +220 -0
  73. package/dist/terminal-wizard.d.ts +2 -0
  74. package/dist/terminal-wizard.js +125 -0
  75. package/package.json +10 -26
  76. package/assets/agents/architect.md +0 -33
  77. package/assets/agents/manager.md +0 -82
  78. package/assets/agents/review.md +0 -25
  79. package/assets/commands/agent-list.md +0 -9
  80. package/assets/commands/agent-model-set.md +0 -9
  81. package/assets/commands/askme.md +0 -10
  82. package/assets/commands/ast-grep-rewrite.md +0 -10
  83. package/assets/commands/ast-grep-search.md +0 -10
  84. package/assets/commands/attempt-cancel.md +0 -10
  85. package/assets/commands/attempt-list.md +0 -10
  86. package/assets/commands/attempt-result.md +0 -10
  87. package/assets/commands/attempt-show.md +0 -10
  88. package/assets/commands/capabilities.md +0 -9
  89. package/assets/commands/code-review.md +0 -10
  90. package/assets/commands/commit-msg.md +0 -10
  91. package/assets/commands/critic-add.md +0 -9
  92. package/assets/commands/critic-remove.md +0 -9
  93. package/assets/commands/docs-prepare.md +0 -10
  94. package/assets/commands/docs-review.md +0 -10
  95. package/assets/commands/doctor.md +0 -9
  96. package/assets/commands/doit.md +0 -10
  97. package/assets/commands/goal-list.md +0 -10
  98. package/assets/commands/goal-pause.md +0 -10
  99. package/assets/commands/goal-prepare.md +0 -10
  100. package/assets/commands/goal-remove.md +0 -10
  101. package/assets/commands/goal-show.md +0 -10
  102. package/assets/commands/goal-start.md +0 -10
  103. package/assets/commands/lsp-report.md +0 -10
  104. package/assets/commands/mattermost.md +0 -10
  105. package/assets/commands/mr-prepare.md +0 -10
  106. package/assets/commands/mr-review.md +0 -10
  107. package/assets/commands/multi-run-cancel.md +0 -10
  108. package/assets/commands/multi-run-compare.md +0 -10
  109. package/assets/commands/multi-run-fusion.md +0 -10
  110. package/assets/commands/multi-run-start.md +0 -10
  111. package/assets/commands/multi-run-status.md +0 -10
  112. package/assets/commands/overview.md +0 -10
  113. package/assets/commands/release-prepare.md +0 -10
  114. package/assets/commands/release-review.md +0 -10
  115. package/assets/commands/route.md +0 -9
  116. package/assets/commands/schedule-add.md +0 -10
  117. package/assets/commands/schedule-disable.md +0 -10
  118. package/assets/commands/schedule-enable.md +0 -10
  119. package/assets/commands/schedule-list.md +0 -10
  120. package/assets/commands/schedule-remove.md +0 -10
  121. package/assets/commands/schedule-status.md +0 -10
  122. package/assets/commands/skill-improver.md +0 -10
  123. package/assets/commands/spec-audit.md +0 -10
  124. package/assets/commands/spec-init.md +0 -10
  125. package/assets/commands/spec-onboard.md +0 -10
  126. package/assets/commands/spec-update.md +0 -10
  127. package/assets/commands/stopit.md +0 -10
  128. package/assets/commands/summary.md +0 -10
  129. package/assets/commands/task-prepare-batch.md +0 -10
  130. package/assets/commands/task-prepare.md +0 -10
  131. package/assets/commands/task-review.md +0 -10
  132. package/assets/commands/task-triage.md +0 -10
  133. package/assets/commands/team-planning.md +0 -10
  134. package/assets/commands/team-retro.md +0 -10
  135. package/assets/commands/team-roadmap.md +0 -10
  136. package/assets/commands/team-slides-prompts.md +0 -10
  137. package/assets/commands/team-sprint-close.md +0 -10
  138. package/assets/commands/team-sprint-status.md +0 -10
  139. package/assets/commands/walkthrough.md +0 -10
  140. package/assets/plugins/autonomy-policy.js +0 -3
  141. package/assets/plugins/background-attempts.js +0 -3
  142. package/assets/plugins/goal-loop.js +0 -3
  143. package/assets/plugins/schedule.js +0 -3
  144. package/assets/plugins/zed-clickable-paths.js +0 -3
  145. package/dist/plugins/autonomy-policy.d.ts +0 -21
  146. package/dist/plugins/autonomy-policy.js +0 -71
  147. package/dist/plugins/background-attempts.d.ts +0 -76
  148. package/dist/plugins/background-attempts.js +0 -113
  149. package/dist/plugins/goal-loop.d.ts +0 -51
  150. package/dist/plugins/goal-loop.js +0 -87
  151. package/dist/plugins/schedule.d.ts +0 -36
  152. package/dist/plugins/schedule.js +0 -100
  153. package/dist/plugins/zed-clickable-paths.d.ts +0 -11
  154. package/dist/plugins/zed-clickable-paths.js +0 -10
  155. /package/{assets → dist/assets}/plugins/rtk.js +0 -0
  156. /package/{assets → dist/assets}/plugins/rules-injector.js +0 -0
  157. /package/{assets → dist/assets}/plugins/zed-bell.js +0 -0
package/dist/index.d.ts CHANGED
@@ -1,29 +1,14 @@
1
- import backgroundAttempts, { type BackgroundAttemptsOptions } from "./plugins/background-attempts.js";
2
- import goalLoop, { type GoalLoopOptions } from "./plugins/goal-loop.js";
3
- import scheduler, { type SchedulerOptions } from "./plugins/schedule.js";
4
- import autonomyPolicy, { type AutonomyPolicyOptions } from "./plugins/autonomy-policy.js";
1
+ import { type PluginInput } from "@opencode-ai/plugin";
5
2
  import rulesInjector, { type RulesInjectorOptions } from "./plugins/rules-injector.js";
6
3
  import rtk, { type RtkOptions } from "./plugins/rtk.js";
7
4
  import zedBell, { type ZedBellOptions } from "./plugins/zed-bell.js";
8
- import zedClickablePaths, { type ZedClickablePathsOptions } from "./plugins/zed-clickable-paths.js";
9
- export { COMMAND_REGISTRY, renderCommand } from "./registry.js";
10
- export { CATEGORIES, resolveRouting, RoutingGate } from "./routing.js";
11
- export { AgentProfileError, FIXED_AGENT_ROLES, applyAgentProfileChange, availableModels, availableModelVariants, listAgentProfiles, previewAgentProfileChange, renderAgentProfile, validateAgentName, validateModel, validateVariant, } from "./agent-profiles.js";
12
- export type { AgentInventory, AgentModelSelection, AgentOwnership, AgentProfileAction, AgentProfileConfig, AgentProfileOperation, AgentProfilePlan, AgentProfileRecord, AgentProfileRequest, AgentProfileResult, AgentProfileScope, AgentState, DeploymentManifest, DeploymentRecord, FixedAgentRole, } from "./agent-profiles.js";
13
- export { backgroundAttempts, goalLoop, scheduler, autonomyPolicy, rulesInjector, rtk, zedBell, zedClickablePaths };
5
+ export { rulesInjector, rtk, zedBell, };
14
6
  export type OpenCodeOptions = {
15
- backgroundAttempts?: BackgroundAttemptsOptions;
16
- goalLoop?: GoalLoopOptions;
17
- scheduler?: SchedulerOptions;
18
- autonomyPolicy?: AutonomyPolicyOptions;
19
7
  rulesInjector?: RulesInjectorOptions;
20
8
  rtk?: RtkOptions;
21
9
  zedBell?: ZedBellOptions;
22
- zedClickablePaths?: ZedClickablePathsOptions;
23
10
  };
24
- declare const plugin: (input: {
25
- directory?: string;
26
- }) => Promise<{
11
+ declare const plugin: (input: PluginInput) => Promise<{
27
12
  tool: {
28
13
  route: {
29
14
  description: string;
@@ -37,18 +22,12 @@ declare const plugin: (input: {
37
22
  exploration: "exploration";
38
23
  architecture: "architecture";
39
24
  implementation: "implementation";
40
- documentation: "documentation";
41
- quick: "quick";
42
25
  }>;
43
26
  task: import("zod").ZodString;
44
27
  requirements: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
45
- agents: import("zod").ZodArray<import("zod").ZodObject<{
46
- agent: import("zod").ZodString;
47
- available: import("zod").ZodOptional<import("zod").ZodBoolean>;
48
- capabilities: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
49
- tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
50
- }, import("zod/v4/core").$strip>>;
28
+ execution_card: import("zod").ZodOptional<import("zod").ZodAny>;
51
29
  override: import("zod").ZodOptional<import("zod").ZodString>;
30
+ trusted_override: import("zod").ZodOptional<import("zod").ZodBoolean>;
52
31
  budget: import("zod").ZodOptional<import("zod").ZodObject<{
53
32
  cost_class: import("zod").ZodOptional<import("zod").ZodString>;
54
33
  latency_class: import("zod").ZodOptional<import("zod").ZodString>;
@@ -57,16 +36,12 @@ declare const plugin: (input: {
57
36
  };
58
37
  execute(args: {
59
38
  action: "preview" | "dispatch";
60
- category: "review" | "exploration" | "architecture" | "implementation" | "documentation" | "quick";
39
+ category: "review" | "exploration" | "architecture" | "implementation";
61
40
  task: string;
62
41
  requirements: string[];
63
- agents: {
64
- agent: string;
65
- available?: boolean | undefined;
66
- capabilities?: string[] | undefined;
67
- tools?: string[] | undefined;
68
- }[];
42
+ execution_card?: any;
69
43
  override?: string | undefined;
44
+ trusted_override?: boolean | undefined;
70
45
  budget?: {
71
46
  cost_class?: string | undefined;
72
47
  latency_class?: string | undefined;
@@ -81,8 +56,15 @@ declare const plugin: (input: {
81
56
  };
82
57
  doctor: {
83
58
  description: string;
84
- args: {};
85
- execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
59
+ args: {
60
+ scope: import("zod").ZodDefault<import("zod").ZodEnum<{
61
+ global: "global";
62
+ project: "project";
63
+ }>>;
64
+ };
65
+ execute(args: {
66
+ scope: "global" | "project";
67
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
86
68
  };
87
69
  agent_profiles: {
88
70
  description: string;
@@ -116,6 +98,25 @@ declare const plugin: (input: {
116
98
  confirmation_digest?: string | undefined;
117
99
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
118
100
  };
101
+ reconcile: {
102
+ description: string;
103
+ args: {
104
+ phase: import("zod").ZodEnum<{
105
+ preview: "preview";
106
+ apply: "apply";
107
+ }>;
108
+ scope: import("zod").ZodEnum<{
109
+ global: "global";
110
+ project: "project";
111
+ }>;
112
+ confirmation_digest: import("zod").ZodOptional<import("zod").ZodString>;
113
+ };
114
+ execute(args: {
115
+ phase: "preview" | "apply";
116
+ scope: "global" | "project";
117
+ confirmation_digest?: string | undefined;
118
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
119
+ };
119
120
  };
120
121
  "tool.execute.before": (input: {
121
122
  tool: string;
@@ -123,10 +124,15 @@ declare const plugin: (input: {
123
124
  }, output: {
124
125
  args: unknown;
125
126
  }) => Promise<void>;
127
+ "tool.execute.after": (input: {
128
+ tool: string;
129
+ sessionID: string;
130
+ args: unknown;
131
+ }, output: {
132
+ output: string;
133
+ }) => Promise<void>;
126
134
  }>;
127
- export declare const server: (input: {
128
- directory?: string;
129
- }) => Promise<{
135
+ export declare const server: (input: PluginInput) => Promise<{
130
136
  tool: {
131
137
  route: {
132
138
  description: string;
@@ -140,18 +146,12 @@ export declare const server: (input: {
140
146
  exploration: "exploration";
141
147
  architecture: "architecture";
142
148
  implementation: "implementation";
143
- documentation: "documentation";
144
- quick: "quick";
145
149
  }>;
146
150
  task: import("zod").ZodString;
147
151
  requirements: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
148
- agents: import("zod").ZodArray<import("zod").ZodObject<{
149
- agent: import("zod").ZodString;
150
- available: import("zod").ZodOptional<import("zod").ZodBoolean>;
151
- capabilities: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
152
- tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
153
- }, import("zod/v4/core").$strip>>;
152
+ execution_card: import("zod").ZodOptional<import("zod").ZodAny>;
154
153
  override: import("zod").ZodOptional<import("zod").ZodString>;
154
+ trusted_override: import("zod").ZodOptional<import("zod").ZodBoolean>;
155
155
  budget: import("zod").ZodOptional<import("zod").ZodObject<{
156
156
  cost_class: import("zod").ZodOptional<import("zod").ZodString>;
157
157
  latency_class: import("zod").ZodOptional<import("zod").ZodString>;
@@ -160,16 +160,12 @@ export declare const server: (input: {
160
160
  };
161
161
  execute(args: {
162
162
  action: "preview" | "dispatch";
163
- category: "review" | "exploration" | "architecture" | "implementation" | "documentation" | "quick";
163
+ category: "review" | "exploration" | "architecture" | "implementation";
164
164
  task: string;
165
165
  requirements: string[];
166
- agents: {
167
- agent: string;
168
- available?: boolean | undefined;
169
- capabilities?: string[] | undefined;
170
- tools?: string[] | undefined;
171
- }[];
166
+ execution_card?: any;
172
167
  override?: string | undefined;
168
+ trusted_override?: boolean | undefined;
173
169
  budget?: {
174
170
  cost_class?: string | undefined;
175
171
  latency_class?: string | undefined;
@@ -184,8 +180,15 @@ export declare const server: (input: {
184
180
  };
185
181
  doctor: {
186
182
  description: string;
187
- args: {};
188
- execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
183
+ args: {
184
+ scope: import("zod").ZodDefault<import("zod").ZodEnum<{
185
+ global: "global";
186
+ project: "project";
187
+ }>>;
188
+ };
189
+ execute(args: {
190
+ scope: "global" | "project";
191
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
189
192
  };
190
193
  agent_profiles: {
191
194
  description: string;
@@ -219,6 +222,25 @@ export declare const server: (input: {
219
222
  confirmation_digest?: string | undefined;
220
223
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
221
224
  };
225
+ reconcile: {
226
+ description: string;
227
+ args: {
228
+ phase: import("zod").ZodEnum<{
229
+ preview: "preview";
230
+ apply: "apply";
231
+ }>;
232
+ scope: import("zod").ZodEnum<{
233
+ global: "global";
234
+ project: "project";
235
+ }>;
236
+ confirmation_digest: import("zod").ZodOptional<import("zod").ZodString>;
237
+ };
238
+ execute(args: {
239
+ phase: "preview" | "apply";
240
+ scope: "global" | "project";
241
+ confirmation_digest?: string | undefined;
242
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
243
+ };
222
244
  };
223
245
  "tool.execute.before": (input: {
224
246
  tool: string;
@@ -226,5 +248,12 @@ export declare const server: (input: {
226
248
  }, output: {
227
249
  args: unknown;
228
250
  }) => Promise<void>;
251
+ "tool.execute.after": (input: {
252
+ tool: string;
253
+ sessionID: string;
254
+ args: unknown;
255
+ }, output: {
256
+ output: string;
257
+ }) => Promise<void>;
229
258
  }>;
230
259
  export default plugin;
package/dist/index.js CHANGED
@@ -1,26 +1,52 @@
1
1
  import { tool } from "@opencode-ai/plugin";
2
- import { CATEGORIES, RoutingGate } from "./routing.js";
3
- import backgroundAttempts from "./plugins/background-attempts.js";
4
- import goalLoop from "./plugins/goal-loop.js";
5
- import scheduler from "./plugins/schedule.js";
6
- import autonomyPolicy from "./plugins/autonomy-policy.js";
2
+ import { CATEGORIES, RoutingGate, } from "./routing.js";
7
3
  import rulesInjector from "./plugins/rules-injector.js";
8
4
  import rtk from "./plugins/rtk.js";
9
5
  import zedBell from "./plugins/zed-bell.js";
10
- import zedClickablePaths from "./plugins/zed-clickable-paths.js";
11
6
  import { applyAgentProfileChange, listAgentProfiles, previewAgentProfileChange, } from "./agent-profiles.js";
12
- export { COMMAND_REGISTRY, renderCommand } from "./registry.js";
13
- export { CATEGORIES, resolveRouting, RoutingGate } from "./routing.js";
14
- export { AgentProfileError, FIXED_AGENT_ROLES, applyAgentProfileChange, availableModels, availableModelVariants, listAgentProfiles, previewAgentProfileChange, renderAgentProfile, validateAgentName, validateModel, validateVariant, } from "./agent-profiles.js";
15
- export { backgroundAttempts, goalLoop, scheduler, autonomyPolicy, rulesInjector, rtk, zedBell, zedClickablePaths };
16
- const CATALOG = {
17
- skills: ["attempt", "goal", "schedule", "multi-run", "usage", "overview", "lsp-report"],
18
- plugins: ["background-attempts", "goal-loop", "schedule", "autonomy-policy", "rules-injector", "rtk", "zed-bell", "zed-clickable-paths"],
19
- replacements: ["capabilities", "route", "doctor", "agent_profiles"],
20
- version: "1.1.1",
21
- };
7
+ import { applyReconcile, previewReconcile } from "./reconcile.js";
8
+ import { collectDoctorFacts } from "./doctor.js";
9
+ import { CATALOG } from "./catalog.js";
10
+ import { digest } from "./lifecycle.js";
11
+ export { rulesInjector, rtk, zedBell, };
22
12
  const plugin = (async (input) => {
23
13
  const gate = new RoutingGate();
14
+ const hostInventory = async () => {
15
+ if (!input.client?.app?.agents)
16
+ throw new Error("Resolved OpenCode agent inventory is unavailable");
17
+ const response = await input.client.app.agents({ query: { directory: input.directory } });
18
+ const raw = response.data;
19
+ if (!Array.isArray(raw))
20
+ throw new Error("Resolved OpenCode agent inventory is malformed");
21
+ const capabilities = {
22
+ mapper: ["read", "search"],
23
+ architect: ["read", "architecture"],
24
+ worker: ["read", "write", "verify"],
25
+ review: ["read", "review"],
26
+ critic: ["read", "review"],
27
+ };
28
+ const agents = raw.map((value) => {
29
+ const agent = value;
30
+ if (typeof agent.name !== "string" || !agent.name)
31
+ throw new Error("Resolved OpenCode agent has no name");
32
+ return {
33
+ agent: agent.name,
34
+ available: true,
35
+ capabilities: capabilities[agent.name] ?? ["read"],
36
+ tools: [
37
+ "read",
38
+ ...(agent.permission?.edit !== "deny" ? ["edit"] : []),
39
+ ...Object.entries(agent.tools ?? {})
40
+ .filter(([, enabled]) => enabled)
41
+ .map(([name]) => name),
42
+ ...Object.entries(agent.permission?.bash ?? {})
43
+ .filter(([, mode]) => mode !== "deny")
44
+ .map(() => "bash"),
45
+ ].filter((name, index, list) => list.indexOf(name) === index),
46
+ };
47
+ });
48
+ return { agents, revision: digest(raw) };
49
+ };
24
50
  const route = tool({
25
51
  description: "Resolve a capability category and dispatch one eligible agent through a one-use Task receipt gate.",
26
52
  args: {
@@ -28,30 +54,61 @@ const plugin = (async (input) => {
28
54
  category: tool.schema.enum(CATEGORIES),
29
55
  task: tool.schema.string(),
30
56
  requirements: tool.schema.array(tool.schema.string()).default([]),
31
- agents: tool.schema.array(tool.schema.object({ agent: tool.schema.string(), available: tool.schema.boolean().optional(), capabilities: tool.schema.array(tool.schema.string()).optional(), tools: tool.schema.array(tool.schema.string()).optional() })),
57
+ execution_card: tool.schema.any().optional(),
32
58
  override: tool.schema.string().optional(),
33
- budget: tool.schema.object({ cost_class: tool.schema.string().optional(), latency_class: tool.schema.string().optional() }).optional(),
34
- decision: tool.schema.any().optional()
59
+ trusted_override: tool.schema.boolean().optional(),
60
+ budget: tool.schema
61
+ .object({
62
+ cost_class: tool.schema.string().optional(),
63
+ latency_class: tool.schema.string().optional(),
64
+ })
65
+ .optional(),
66
+ decision: tool.schema.any().optional(),
35
67
  },
36
68
  async execute(args, context) {
37
- const input = { category: args.category, requirements: args.requirements, agents: args.agents, override: args.override, budget: args.budget };
69
+ const inventory = await hostInventory();
70
+ const input = {
71
+ category: args.category,
72
+ task: args.task,
73
+ requirements: args.requirements,
74
+ agents: inventory.agents,
75
+ inventory_revision: inventory.revision,
76
+ execution_card: args.execution_card,
77
+ override: args.override,
78
+ trusted_override: args.trusted_override,
79
+ budget: args.budget,
80
+ };
38
81
  if (args.action === "preview")
39
82
  return JSON.stringify(gate.preview(input));
40
83
  const decision = gate.dispatch(input, args.decision);
41
- gate.grant(context.sessionID, decision);
42
- return JSON.stringify({ decision, status: "routed" });
43
- }
84
+ if (decision.agent === "worker" && args.execution_card === undefined)
85
+ throw new Error("implementation dispatch requires a confirmed execution card");
86
+ const receipt = gate.grant(context.sessionID, decision, {
87
+ task: args.task,
88
+ requirements: args.requirements,
89
+ card: args.execution_card,
90
+ });
91
+ return JSON.stringify({ decision, receipt, status: "routed" });
92
+ },
44
93
  });
45
94
  const capabilities = tool({
46
95
  description: "Show the bundled OpenCode capability catalog without installing or changing anything.",
47
96
  args: {},
48
- async execute() { return JSON.stringify({ schema_version: 1, status: "ok", ...CATALOG }); },
97
+ async execute() {
98
+ return JSON.stringify({ schema_version: 1, status: "ok", ...CATALOG });
99
+ },
49
100
  });
50
101
  const doctor = tool({
51
102
  description: "Read package health and opt-in defaults without installing or repairing anything.",
52
- args: {},
53
- async execute() {
54
- return JSON.stringify({ schema_version: 1, status: "ok", package: "@kisev/skills-opencode", opencode: ">=1.18.29", state: "not-inspected", mutations: false, defaults: { backgroundAttempts: false, goalLoop: false, scheduler: false, autonomyPolicy: false, zedBell: false, zedClickablePaths: false } });
103
+ args: { scope: tool.schema.enum(["global", "project"]).default("project") },
104
+ async execute(args, context) {
105
+ const host = input.client
106
+ ? {
107
+ config: async () => (await input.client.config.get({ query: { directory: context.directory } })).data,
108
+ lsp: async () => (await input.client.lsp.status({ query: { directory: context.directory } })).data,
109
+ }
110
+ : undefined;
111
+ return JSON.stringify(await collectDoctorFacts(args.scope ?? "project", context.directory, undefined, host));
55
112
  },
56
113
  });
57
114
  const agentProfiles = tool({
@@ -68,32 +125,108 @@ const plugin = (async (input) => {
68
125
  async execute(args) {
69
126
  const cwd = input.directory ?? process.cwd();
70
127
  if (args.action === "list") {
71
- if (args.phase || args.name || args.model || args.variant !== undefined || args.confirmation_digest)
128
+ if (args.phase ||
129
+ args.name ||
130
+ args.model ||
131
+ args.variant !== undefined ||
132
+ args.confirmation_digest)
72
133
  throw new Error("agent_profiles list accepts only scope");
73
- return JSON.stringify({ status: "ok", inventory: await listAgentProfiles(args.scope, cwd) });
134
+ return JSON.stringify({
135
+ status: "ok",
136
+ inventory: await listAgentProfiles(args.scope, cwd),
137
+ });
74
138
  }
75
139
  if (!args.phase)
76
140
  throw new Error("agent_profiles mutation requires preview or apply phase");
77
- const action = { model_set: "model-set", critic_add: "critic-add", critic_remove: "critic-remove" }[args.action];
78
- const request = { action, ...(args.name ? { name: args.name } : {}), ...(args.model ? { model: args.model } : {}), ...(args.variant !== undefined ? { variant: args.variant } : {}) };
141
+ const action = {
142
+ model_set: "model-set",
143
+ critic_add: "critic-add",
144
+ critic_remove: "critic-remove",
145
+ }[args.action];
146
+ const request = {
147
+ action,
148
+ ...(args.name ? { name: args.name } : {}),
149
+ ...(args.model ? { model: args.model } : {}),
150
+ ...(args.variant !== undefined ? { variant: args.variant } : {}),
151
+ };
79
152
  if (args.phase === "preview")
80
- return JSON.stringify({ status: "ok", applied: false, requires_restart: false, plan: await previewAgentProfileChange(request, args.scope, cwd) });
153
+ return JSON.stringify({
154
+ status: "ok",
155
+ applied: false,
156
+ requires_restart: false,
157
+ plan: await previewAgentProfileChange(request, args.scope, cwd),
158
+ });
81
159
  if (!args.confirmation_digest)
82
160
  throw new Error("agent_profiles apply requires confirmation_digest");
83
161
  return JSON.stringify(await applyAgentProfileChange(request, args.scope, args.confirmation_digest, cwd));
84
162
  },
85
163
  });
164
+ const reconcile = tool({
165
+ description: "Preview or apply scope-isolated removal of retired public assets without touching unknown sources or runtime state.",
166
+ args: {
167
+ phase: tool.schema.enum(["preview", "apply"]),
168
+ scope: tool.schema.enum(["global", "project"]),
169
+ confirmation_digest: tool.schema.string().optional(),
170
+ },
171
+ async execute(args) {
172
+ const cwd = input.directory ?? process.cwd();
173
+ if (args.phase === "preview")
174
+ return JSON.stringify({
175
+ status: "ok",
176
+ applied: false,
177
+ plan: await previewReconcile(args.scope, cwd),
178
+ });
179
+ if (!args.confirmation_digest)
180
+ throw new Error("reconcile apply requires confirmation_digest");
181
+ return JSON.stringify(await applyReconcile(args.scope, args.confirmation_digest, cwd));
182
+ },
183
+ });
86
184
  return {
87
- tool: { route, capabilities, doctor, agent_profiles: agentProfiles },
185
+ tool: { route, capabilities, doctor, agent_profiles: agentProfiles, reconcile },
88
186
  "tool.execute.before": async (input, output) => {
89
187
  if (input.tool !== "task")
90
188
  return;
91
- const args = output.args && typeof output.args === "object" ? output.args : {};
92
- const agent = typeof args.agent === "string" ? args.agent : typeof args.subagent_type === "string" ? args.subagent_type : undefined;
189
+ const args = output.args && typeof output.args === "object"
190
+ ? output.args
191
+ : {};
192
+ const agent = typeof args.agent === "string"
193
+ ? args.agent
194
+ : typeof args.subagent_type === "string"
195
+ ? args.subagent_type
196
+ : undefined;
93
197
  if (!agent)
94
198
  throw new Error("Native Task requires an explicit agent and an active routing receipt");
95
- gate.consume(input.sessionID, agent);
96
- }
199
+ const hasBinding = "task" in args || "requirements" in args || "execution_card" in args;
200
+ if (!hasBinding)
201
+ gate.consume(input.sessionID, agent);
202
+ else {
203
+ const task = typeof args.task === "string" ? args.task : "";
204
+ const requirements = Array.isArray(args.requirements)
205
+ ? args.requirements
206
+ : [];
207
+ gate.consume(input.sessionID, agent, { task, requirements, card: args.execution_card });
208
+ }
209
+ },
210
+ "tool.execute.after": async (input, output) => {
211
+ if (input.tool !== "task")
212
+ return;
213
+ const args = input.args && typeof input.args === "object" ? input.args : {};
214
+ const agent = typeof args.agent === "string"
215
+ ? args.agent
216
+ : typeof args.subagent_type === "string"
217
+ ? args.subagent_type
218
+ : undefined;
219
+ if (!agent)
220
+ throw new Error("Task result requires an explicit agent");
221
+ let result;
222
+ try {
223
+ result = JSON.parse(output.output);
224
+ }
225
+ catch {
226
+ throw new Error("Task result must be JSON structured report");
227
+ }
228
+ gate.complete(input.sessionID, agent, result);
229
+ },
97
230
  };
98
231
  });
99
232
  export const server = plugin;
@@ -1,26 +1,54 @@
1
- import { LifecycleError, type Scope, type TransactionOptions } from "./lifecycle.js";
1
+ import { LifecycleError, type FileMutation, type Scope, type TransactionOptions } from "./lifecycle.js";
2
+ import { CATALOG } from "./catalog.js";
3
+ import { type FixedAgentRole } from "./agent-profiles.js";
2
4
  export type { Scope } from "./lifecycle.js";
3
5
  export type Action = "install" | "uninstall";
4
- export type Operation = "create" | "update" | "remove" | "unchanged" | "missing" | "conflict";
6
+ export type Operation = "create" | "update" | "remove" | "unchanged" | "missing" | "conflict" | "archive-pending";
5
7
  export type PlanItem = {
6
8
  path: string;
7
9
  operation: Operation;
8
10
  reason?: string;
9
11
  sha256?: string;
10
12
  };
13
+ export type SelectablePlugin = (typeof CATALOG.plugins)[number];
14
+ export type InstallerSelection = {
15
+ commands: string[];
16
+ agents: FixedAgentRole[];
17
+ plugins: SelectablePlugin[];
18
+ core_activation: boolean;
19
+ };
11
20
  export type Plan = {
12
- schema_version: 1;
21
+ schema_version: 2;
13
22
  action: Action;
14
23
  scope: Scope;
15
24
  root: string;
16
25
  package_version: string;
26
+ selection: InstallerSelection;
17
27
  operations: PlanItem[];
18
28
  digest: string;
19
29
  receipt_expires_at?: string;
20
30
  requires_restart: boolean;
21
31
  };
32
+ type ManifestFile = {
33
+ sha256: string;
34
+ mode: number;
35
+ kind: "command" | "agent" | "plugin" | "state";
36
+ };
37
+ export type ArchiveCandidate = {
38
+ path: string;
39
+ record: ManifestFile;
40
+ content: Buffer;
41
+ reason: string;
42
+ kind: "command" | "agent" | "plugin" | "state";
43
+ };
44
+ export declare const SELECTABLE_PLUGINS: SelectablePlugin[];
45
+ export declare const PACKAGE_COMMANDS: string[];
46
+ export declare const SKILL_COMMANDS: string[];
47
+ export declare function defaultSelection(): InstallerSelection;
48
+ export declare function normalizeSelection(value?: Partial<InstallerSelection>): InstallerSelection;
22
49
  export declare class InstallerError extends LifecycleError {
23
50
  }
24
- export declare function preview(action: Action, scope: Scope, cwd?: string, home?: string): Promise<Plan>;
25
- export declare function apply(action: Action, scope: Scope, confirmationDigest: string, cwd?: string, home?: string, options?: TransactionOptions): Promise<Plan>;
51
+ export declare function archiveMutations(candidates: readonly ArchiveCandidate[], scope: Scope, cwd: string, home: string, sourceVersion: string): Promise<FileMutation[]>;
52
+ export declare function preview(action: Action, scope: Scope, cwd?: string, home?: string, selection?: Partial<InstallerSelection>): Promise<Plan>;
53
+ export declare function apply(action: Action, scope: Scope, confirmationDigest: string, cwd?: string, home?: string, options?: TransactionOptions, selection?: Partial<InstallerSelection>): Promise<Plan>;
26
54
  export declare function result(plan: Plan, applied: boolean): string;