@kisev/skills-opencode 1.2.0 → 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 (153) hide show
  1. package/README.md +134 -112
  2. package/README.ru.md +242 -0
  3. package/dist/agent-profiles.d.ts +1 -1
  4. package/dist/agent-profiles.js +18 -9
  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 +136 -10
  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 +80 -56
  57. package/dist/index.js +162 -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 +39 -2
  68. package/dist/routing.js +339 -27
  69. package/dist/runtime/worktree.d.ts +33 -0
  70. package/dist/runtime/worktree.js +220 -0
  71. package/package.json +10 -26
  72. package/assets/agents/architect.md +0 -33
  73. package/assets/agents/manager.md +0 -82
  74. package/assets/agents/review.md +0 -25
  75. package/assets/commands/agent-list.md +0 -9
  76. package/assets/commands/agent-model-set.md +0 -9
  77. package/assets/commands/askme.md +0 -10
  78. package/assets/commands/ast-grep-rewrite.md +0 -10
  79. package/assets/commands/ast-grep-search.md +0 -10
  80. package/assets/commands/attempt-cancel.md +0 -10
  81. package/assets/commands/attempt-list.md +0 -10
  82. package/assets/commands/attempt-result.md +0 -10
  83. package/assets/commands/attempt-show.md +0 -10
  84. package/assets/commands/capabilities.md +0 -9
  85. package/assets/commands/code-review.md +0 -10
  86. package/assets/commands/commit-msg.md +0 -10
  87. package/assets/commands/critic-add.md +0 -9
  88. package/assets/commands/critic-remove.md +0 -9
  89. package/assets/commands/docs-prepare.md +0 -10
  90. package/assets/commands/docs-review.md +0 -10
  91. package/assets/commands/doctor.md +0 -9
  92. package/assets/commands/doit.md +0 -10
  93. package/assets/commands/goal-list.md +0 -10
  94. package/assets/commands/goal-pause.md +0 -10
  95. package/assets/commands/goal-prepare.md +0 -10
  96. package/assets/commands/goal-remove.md +0 -10
  97. package/assets/commands/goal-show.md +0 -10
  98. package/assets/commands/goal-start.md +0 -10
  99. package/assets/commands/lsp-report.md +0 -10
  100. package/assets/commands/mattermost.md +0 -10
  101. package/assets/commands/mr-prepare.md +0 -10
  102. package/assets/commands/mr-review.md +0 -10
  103. package/assets/commands/multi-run-cancel.md +0 -10
  104. package/assets/commands/multi-run-compare.md +0 -10
  105. package/assets/commands/multi-run-fusion.md +0 -10
  106. package/assets/commands/multi-run-start.md +0 -10
  107. package/assets/commands/multi-run-status.md +0 -10
  108. package/assets/commands/overview.md +0 -10
  109. package/assets/commands/release-prepare.md +0 -10
  110. package/assets/commands/release-review.md +0 -10
  111. package/assets/commands/route.md +0 -9
  112. package/assets/commands/schedule-add.md +0 -10
  113. package/assets/commands/schedule-disable.md +0 -10
  114. package/assets/commands/schedule-enable.md +0 -10
  115. package/assets/commands/schedule-list.md +0 -10
  116. package/assets/commands/schedule-remove.md +0 -10
  117. package/assets/commands/schedule-status.md +0 -10
  118. package/assets/commands/skill-improver.md +0 -10
  119. package/assets/commands/spec-audit.md +0 -10
  120. package/assets/commands/spec-init.md +0 -10
  121. package/assets/commands/spec-onboard.md +0 -10
  122. package/assets/commands/spec-update.md +0 -10
  123. package/assets/commands/stopit.md +0 -10
  124. package/assets/commands/summary.md +0 -10
  125. package/assets/commands/task-prepare-batch.md +0 -10
  126. package/assets/commands/task-prepare.md +0 -10
  127. package/assets/commands/task-review.md +0 -10
  128. package/assets/commands/task-triage.md +0 -10
  129. package/assets/commands/team-planning.md +0 -10
  130. package/assets/commands/team-retro.md +0 -10
  131. package/assets/commands/team-roadmap.md +0 -10
  132. package/assets/commands/team-slides-prompts.md +0 -10
  133. package/assets/commands/team-sprint-close.md +0 -10
  134. package/assets/commands/team-sprint-status.md +0 -10
  135. package/assets/commands/walkthrough.md +0 -10
  136. package/assets/plugins/autonomy-policy.js +0 -3
  137. package/assets/plugins/background-attempts.js +0 -3
  138. package/assets/plugins/goal-loop.js +0 -3
  139. package/assets/plugins/schedule.js +0 -3
  140. package/assets/plugins/zed-clickable-paths.js +0 -3
  141. package/dist/plugins/autonomy-policy.d.ts +0 -21
  142. package/dist/plugins/autonomy-policy.js +0 -71
  143. package/dist/plugins/background-attempts.d.ts +0 -76
  144. package/dist/plugins/background-attempts.js +0 -124
  145. package/dist/plugins/goal-loop.d.ts +0 -62
  146. package/dist/plugins/goal-loop.js +0 -99
  147. package/dist/plugins/schedule.d.ts +0 -36
  148. package/dist/plugins/schedule.js +0 -100
  149. package/dist/plugins/zed-clickable-paths.d.ts +0 -11
  150. package/dist/plugins/zed-clickable-paths.js +0 -10
  151. /package/{assets → dist/assets}/plugins/rtk.js +0 -0
  152. /package/{assets → dist/assets}/plugins/rules-injector.js +0 -0
  153. /package/{assets → dist/assets}/plugins/zed-bell.js +0 -0
package/dist/index.d.ts CHANGED
@@ -1,30 +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, ExecutionCardLifecycle, validateExecutionCard } from "./routing.js";
11
- export type { ExecutionCard, ExecutionCardStatus } from "./routing.js";
12
- export { AgentProfileError, FIXED_AGENT_ROLES, applyAgentProfileChange, availableModels, availableModelVariants, listAgentProfiles, previewAgentProfileChange, renderAgentProfile, validateAgentName, validateModel, validateVariant, } from "./agent-profiles.js";
13
- export type { AgentInventory, AgentModelSelection, AgentOwnership, AgentProfileAction, AgentProfileConfig, AgentProfileOperation, AgentProfilePlan, AgentProfileRecord, AgentProfileRequest, AgentProfileResult, AgentProfileScope, AgentState, DeploymentManifest, DeploymentRecord, FixedAgentRole, } from "./agent-profiles.js";
14
- export { backgroundAttempts, goalLoop, scheduler, autonomyPolicy, rulesInjector, rtk, zedBell, zedClickablePaths };
5
+ export { rulesInjector, rtk, zedBell, };
15
6
  export type OpenCodeOptions = {
16
- backgroundAttempts?: BackgroundAttemptsOptions;
17
- goalLoop?: GoalLoopOptions;
18
- scheduler?: SchedulerOptions;
19
- autonomyPolicy?: AutonomyPolicyOptions;
20
7
  rulesInjector?: RulesInjectorOptions;
21
8
  rtk?: RtkOptions;
22
9
  zedBell?: ZedBellOptions;
23
- zedClickablePaths?: ZedClickablePathsOptions;
24
10
  };
25
- declare const plugin: (input: {
26
- directory?: string;
27
- }) => Promise<{
11
+ declare const plugin: (input: PluginInput) => Promise<{
28
12
  tool: {
29
13
  route: {
30
14
  description: string;
@@ -38,19 +22,12 @@ declare const plugin: (input: {
38
22
  exploration: "exploration";
39
23
  architecture: "architecture";
40
24
  implementation: "implementation";
41
- documentation: "documentation";
42
- quick: "quick";
43
25
  }>;
44
26
  task: import("zod").ZodString;
45
27
  requirements: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
46
- agents: import("zod").ZodArray<import("zod").ZodObject<{
47
- agent: import("zod").ZodString;
48
- available: import("zod").ZodOptional<import("zod").ZodBoolean>;
49
- capabilities: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
50
- tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
51
- }, import("zod/v4/core").$strip>>;
52
28
  execution_card: import("zod").ZodOptional<import("zod").ZodAny>;
53
29
  override: import("zod").ZodOptional<import("zod").ZodString>;
30
+ trusted_override: import("zod").ZodOptional<import("zod").ZodBoolean>;
54
31
  budget: import("zod").ZodOptional<import("zod").ZodObject<{
55
32
  cost_class: import("zod").ZodOptional<import("zod").ZodString>;
56
33
  latency_class: import("zod").ZodOptional<import("zod").ZodString>;
@@ -59,17 +36,12 @@ declare const plugin: (input: {
59
36
  };
60
37
  execute(args: {
61
38
  action: "preview" | "dispatch";
62
- category: "review" | "exploration" | "architecture" | "implementation" | "documentation" | "quick";
39
+ category: "review" | "exploration" | "architecture" | "implementation";
63
40
  task: string;
64
41
  requirements: string[];
65
- agents: {
66
- agent: string;
67
- available?: boolean | undefined;
68
- capabilities?: string[] | undefined;
69
- tools?: string[] | undefined;
70
- }[];
71
42
  execution_card?: any;
72
43
  override?: string | undefined;
44
+ trusted_override?: boolean | undefined;
73
45
  budget?: {
74
46
  cost_class?: string | undefined;
75
47
  latency_class?: string | undefined;
@@ -84,8 +56,15 @@ declare const plugin: (input: {
84
56
  };
85
57
  doctor: {
86
58
  description: string;
87
- args: {};
88
- 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>;
89
68
  };
90
69
  agent_profiles: {
91
70
  description: string;
@@ -119,6 +98,25 @@ declare const plugin: (input: {
119
98
  confirmation_digest?: string | undefined;
120
99
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
121
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
+ };
122
120
  };
123
121
  "tool.execute.before": (input: {
124
122
  tool: string;
@@ -126,10 +124,15 @@ declare const plugin: (input: {
126
124
  }, output: {
127
125
  args: unknown;
128
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>;
129
134
  }>;
130
- export declare const server: (input: {
131
- directory?: string;
132
- }) => Promise<{
135
+ export declare const server: (input: PluginInput) => Promise<{
133
136
  tool: {
134
137
  route: {
135
138
  description: string;
@@ -143,19 +146,12 @@ export declare const server: (input: {
143
146
  exploration: "exploration";
144
147
  architecture: "architecture";
145
148
  implementation: "implementation";
146
- documentation: "documentation";
147
- quick: "quick";
148
149
  }>;
149
150
  task: import("zod").ZodString;
150
151
  requirements: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
151
- agents: import("zod").ZodArray<import("zod").ZodObject<{
152
- agent: import("zod").ZodString;
153
- available: import("zod").ZodOptional<import("zod").ZodBoolean>;
154
- capabilities: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
155
- tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
156
- }, import("zod/v4/core").$strip>>;
157
152
  execution_card: import("zod").ZodOptional<import("zod").ZodAny>;
158
153
  override: import("zod").ZodOptional<import("zod").ZodString>;
154
+ trusted_override: import("zod").ZodOptional<import("zod").ZodBoolean>;
159
155
  budget: import("zod").ZodOptional<import("zod").ZodObject<{
160
156
  cost_class: import("zod").ZodOptional<import("zod").ZodString>;
161
157
  latency_class: import("zod").ZodOptional<import("zod").ZodString>;
@@ -164,17 +160,12 @@ export declare const server: (input: {
164
160
  };
165
161
  execute(args: {
166
162
  action: "preview" | "dispatch";
167
- category: "review" | "exploration" | "architecture" | "implementation" | "documentation" | "quick";
163
+ category: "review" | "exploration" | "architecture" | "implementation";
168
164
  task: string;
169
165
  requirements: string[];
170
- agents: {
171
- agent: string;
172
- available?: boolean | undefined;
173
- capabilities?: string[] | undefined;
174
- tools?: string[] | undefined;
175
- }[];
176
166
  execution_card?: any;
177
167
  override?: string | undefined;
168
+ trusted_override?: boolean | undefined;
178
169
  budget?: {
179
170
  cost_class?: string | undefined;
180
171
  latency_class?: string | undefined;
@@ -189,8 +180,15 @@ export declare const server: (input: {
189
180
  };
190
181
  doctor: {
191
182
  description: string;
192
- args: {};
193
- 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>;
194
192
  };
195
193
  agent_profiles: {
196
194
  description: string;
@@ -224,6 +222,25 @@ export declare const server: (input: {
224
222
  confirmation_digest?: string | undefined;
225
223
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
226
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
+ };
227
244
  };
228
245
  "tool.execute.before": (input: {
229
246
  tool: string;
@@ -231,5 +248,12 @@ export declare const server: (input: {
231
248
  }, output: {
232
249
  args: unknown;
233
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>;
234
258
  }>;
235
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, ExecutionCardLifecycle, validateExecutionCard } 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,31 +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() })),
32
57
  execution_card: tool.schema.any().optional(),
33
58
  override: tool.schema.string().optional(),
34
- budget: tool.schema.object({ cost_class: tool.schema.string().optional(), latency_class: tool.schema.string().optional() }).optional(),
35
- 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(),
36
67
  },
37
68
  async execute(args, context) {
38
- const input = { category: args.category, task: args.task, requirements: args.requirements, agents: args.agents, execution_card: args.execution_card, 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
+ };
39
81
  if (args.action === "preview")
40
82
  return JSON.stringify(gate.preview(input));
41
83
  const decision = gate.dispatch(input, args.decision);
42
- gate.grant(context.sessionID, decision, { task: args.task, requirements: args.requirements, card: args.execution_card });
43
- return JSON.stringify({ decision, status: "routed" });
44
- }
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
+ },
45
93
  });
46
94
  const capabilities = tool({
47
95
  description: "Show the bundled OpenCode capability catalog without installing or changing anything.",
48
96
  args: {},
49
- 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
+ },
50
100
  });
51
101
  const doctor = tool({
52
102
  description: "Read package health and opt-in defaults without installing or repairing anything.",
53
- args: {},
54
- async execute() {
55
- 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));
56
112
  },
57
113
  });
58
114
  const agentProfiles = tool({
@@ -69,28 +125,75 @@ const plugin = (async (input) => {
69
125
  async execute(args) {
70
126
  const cwd = input.directory ?? process.cwd();
71
127
  if (args.action === "list") {
72
- 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)
73
133
  throw new Error("agent_profiles list accepts only scope");
74
- 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
+ });
75
138
  }
76
139
  if (!args.phase)
77
140
  throw new Error("agent_profiles mutation requires preview or apply phase");
78
- const action = { model_set: "model-set", critic_add: "critic-add", critic_remove: "critic-remove" }[args.action];
79
- 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
+ };
80
152
  if (args.phase === "preview")
81
- 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
+ });
82
159
  if (!args.confirmation_digest)
83
160
  throw new Error("agent_profiles apply requires confirmation_digest");
84
161
  return JSON.stringify(await applyAgentProfileChange(request, args.scope, args.confirmation_digest, cwd));
85
162
  },
86
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
+ });
87
184
  return {
88
- tool: { route, capabilities, doctor, agent_profiles: agentProfiles },
185
+ tool: { route, capabilities, doctor, agent_profiles: agentProfiles, reconcile },
89
186
  "tool.execute.before": async (input, output) => {
90
187
  if (input.tool !== "task")
91
188
  return;
92
- const args = output.args && typeof output.args === "object" ? output.args : {};
93
- 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;
94
197
  if (!agent)
95
198
  throw new Error("Native Task requires an explicit agent and an active routing receipt");
96
199
  const hasBinding = "task" in args || "requirements" in args || "execution_card" in args;
@@ -98,10 +201,32 @@ const plugin = (async (input) => {
98
201
  gate.consume(input.sessionID, agent);
99
202
  else {
100
203
  const task = typeof args.task === "string" ? args.task : "";
101
- const requirements = Array.isArray(args.requirements) ? args.requirements : [];
204
+ const requirements = Array.isArray(args.requirements)
205
+ ? args.requirements
206
+ : [];
102
207
  gate.consume(input.sessionID, agent, { task, requirements, card: args.execution_card });
103
208
  }
104
- }
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
+ },
105
230
  };
106
231
  });
107
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;