opencode-hive 0.6.0 → 0.8.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.
Files changed (48) hide show
  1. package/dist/index.js +19268 -479
  2. package/package.json +4 -3
  3. package/dist/e2e/opencode-runtime-smoke.test.d.ts +0 -1
  4. package/dist/e2e/opencode-runtime-smoke.test.js +0 -243
  5. package/dist/e2e/plugin-smoke.test.d.ts +0 -1
  6. package/dist/e2e/plugin-smoke.test.js +0 -127
  7. package/dist/services/contextService.d.ts +0 -15
  8. package/dist/services/contextService.js +0 -59
  9. package/dist/services/featureService.d.ts +0 -14
  10. package/dist/services/featureService.js +0 -107
  11. package/dist/services/featureService.test.d.ts +0 -1
  12. package/dist/services/featureService.test.js +0 -127
  13. package/dist/services/index.d.ts +0 -5
  14. package/dist/services/index.js +0 -4
  15. package/dist/services/planService.d.ts +0 -11
  16. package/dist/services/planService.js +0 -59
  17. package/dist/services/planService.test.d.ts +0 -1
  18. package/dist/services/planService.test.js +0 -115
  19. package/dist/services/sessionService.d.ts +0 -31
  20. package/dist/services/sessionService.js +0 -125
  21. package/dist/services/taskService.d.ts +0 -17
  22. package/dist/services/taskService.js +0 -230
  23. package/dist/services/taskService.test.d.ts +0 -1
  24. package/dist/services/taskService.test.js +0 -159
  25. package/dist/services/worktreeService.d.ts +0 -66
  26. package/dist/services/worktreeService.js +0 -498
  27. package/dist/services/worktreeService.test.d.ts +0 -1
  28. package/dist/services/worktreeService.test.js +0 -185
  29. package/dist/tools/contextTools.d.ts +0 -93
  30. package/dist/tools/contextTools.js +0 -83
  31. package/dist/tools/execTools.d.ts +0 -66
  32. package/dist/tools/execTools.js +0 -125
  33. package/dist/tools/featureTools.d.ts +0 -60
  34. package/dist/tools/featureTools.js +0 -73
  35. package/dist/tools/planTools.d.ts +0 -47
  36. package/dist/tools/planTools.js +0 -65
  37. package/dist/tools/sessionTools.d.ts +0 -35
  38. package/dist/tools/sessionTools.js +0 -95
  39. package/dist/tools/taskTools.d.ts +0 -79
  40. package/dist/tools/taskTools.js +0 -86
  41. package/dist/types.d.ts +0 -89
  42. package/dist/types.js +0 -1
  43. package/dist/utils/detection.d.ts +0 -12
  44. package/dist/utils/detection.js +0 -73
  45. package/dist/utils/paths.d.ts +0 -18
  46. package/dist/utils/paths.js +0 -74
  47. package/dist/utils/paths.test.d.ts +0 -1
  48. package/dist/utils/paths.test.js +0 -100
@@ -1,93 +0,0 @@
1
- import { z } from 'zod';
2
- export declare function createContextTools(projectRoot: string): {
3
- hive_context_write: {
4
- description: string;
5
- parameters: z.ZodObject<{
6
- name: z.ZodString;
7
- content: z.ZodString;
8
- }, z.core.$strip>;
9
- execute: ({ name, content }: {
10
- name: string;
11
- content: string;
12
- }) => Promise<{
13
- error: string;
14
- success?: undefined;
15
- path?: undefined;
16
- } | {
17
- success: boolean;
18
- path: string;
19
- error?: undefined;
20
- }>;
21
- };
22
- hive_context_read: {
23
- description: string;
24
- parameters: z.ZodObject<{
25
- name: z.ZodOptional<z.ZodString>;
26
- }, z.core.$strip>;
27
- execute: ({ name }: {
28
- name?: string;
29
- }) => Promise<{
30
- error: string;
31
- name?: undefined;
32
- content?: undefined;
33
- message?: undefined;
34
- compiled?: undefined;
35
- } | {
36
- name: string;
37
- content: string;
38
- error?: undefined;
39
- message?: undefined;
40
- compiled?: undefined;
41
- } | {
42
- message: string;
43
- error?: undefined;
44
- name?: undefined;
45
- content?: undefined;
46
- compiled?: undefined;
47
- } | {
48
- compiled: string;
49
- error?: undefined;
50
- name?: undefined;
51
- content?: undefined;
52
- message?: undefined;
53
- }>;
54
- };
55
- hive_context_list: {
56
- description: string;
57
- parameters: z.ZodObject<{}, z.core.$strip>;
58
- execute: () => Promise<{
59
- error: string;
60
- files?: undefined;
61
- message?: undefined;
62
- } | {
63
- files: never[];
64
- message: string;
65
- error?: undefined;
66
- } | {
67
- files: {
68
- name: string;
69
- updatedAt: string;
70
- previewLength: number;
71
- }[];
72
- error?: undefined;
73
- message?: undefined;
74
- }>;
75
- };
76
- hive_context_delete: {
77
- description: string;
78
- parameters: z.ZodObject<{
79
- name: z.ZodString;
80
- }, z.core.$strip>;
81
- execute: ({ name }: {
82
- name: string;
83
- }) => Promise<{
84
- error: string;
85
- success?: undefined;
86
- deleted?: undefined;
87
- } | {
88
- success: boolean;
89
- deleted: string;
90
- error?: undefined;
91
- }>;
92
- };
93
- };
@@ -1,83 +0,0 @@
1
- import { z } from 'zod';
2
- import { ContextService } from '../services/contextService.js';
3
- import { FeatureService } from '../services/featureService.js';
4
- import { detectContext } from '../utils/detection.js';
5
- export function createContextTools(projectRoot) {
6
- const contextService = new ContextService(projectRoot);
7
- const featureService = new FeatureService(projectRoot);
8
- const getActiveFeature = () => {
9
- const ctx = detectContext(projectRoot);
10
- return ctx?.feature || null;
11
- };
12
- return {
13
- hive_context_write: {
14
- description: 'Write a context file for the active feature. Context files store persistent notes, decisions, and reference material.',
15
- parameters: z.object({
16
- name: z.string().describe('Context file name (e.g., "architecture", "decisions", "notes")'),
17
- content: z.string().describe('Markdown content to write'),
18
- }),
19
- execute: async ({ name, content }) => {
20
- const feature = getActiveFeature();
21
- if (!feature)
22
- return { error: 'No active feature' };
23
- const filePath = contextService.write(feature, name, content);
24
- return { success: true, path: filePath };
25
- },
26
- },
27
- hive_context_read: {
28
- description: 'Read a specific context file or all context for the active feature',
29
- parameters: z.object({
30
- name: z.string().optional().describe('Context file name. If omitted, returns all context compiled.'),
31
- }),
32
- execute: async ({ name }) => {
33
- const feature = getActiveFeature();
34
- if (!feature)
35
- return { error: 'No active feature' };
36
- if (name) {
37
- const content = contextService.read(feature, name);
38
- if (!content)
39
- return { error: `Context file '${name}' not found` };
40
- return { name, content };
41
- }
42
- const compiled = contextService.compile(feature);
43
- if (!compiled)
44
- return { message: 'No context files found' };
45
- return { compiled };
46
- },
47
- },
48
- hive_context_list: {
49
- description: 'List all context files for the active feature',
50
- parameters: z.object({}),
51
- execute: async () => {
52
- const feature = getActiveFeature();
53
- if (!feature)
54
- return { error: 'No active feature' };
55
- const files = contextService.list(feature);
56
- if (files.length === 0)
57
- return { files: [], message: 'No context files' };
58
- return {
59
- files: files.map(f => ({
60
- name: f.name,
61
- updatedAt: f.updatedAt,
62
- previewLength: f.content.length,
63
- })),
64
- };
65
- },
66
- },
67
- hive_context_delete: {
68
- description: 'Delete a context file',
69
- parameters: z.object({
70
- name: z.string().describe('Context file name to delete'),
71
- }),
72
- execute: async ({ name }) => {
73
- const feature = getActiveFeature();
74
- if (!feature)
75
- return { error: 'No active feature' };
76
- const deleted = contextService.delete(feature, name);
77
- if (!deleted)
78
- return { error: `Context file '${name}' not found` };
79
- return { success: true, deleted: name };
80
- },
81
- },
82
- };
83
- }
@@ -1,66 +0,0 @@
1
- import { z } from 'zod';
2
- export declare function createExecTools(projectRoot: string): {
3
- hive_exec_start: {
4
- description: string;
5
- parameters: z.ZodObject<{
6
- task: z.ZodString;
7
- }, z.core.$strip>;
8
- execute: ({ task }: {
9
- task: string;
10
- }) => Promise<{
11
- error: string;
12
- worktreePath?: undefined;
13
- branch?: undefined;
14
- message?: undefined;
15
- } | {
16
- worktreePath: string;
17
- branch: string;
18
- message: string;
19
- error?: undefined;
20
- }>;
21
- };
22
- hive_exec_complete: {
23
- description: string;
24
- parameters: z.ZodObject<{
25
- task: z.ZodString;
26
- summary: z.ZodString;
27
- report: z.ZodOptional<z.ZodString>;
28
- }, z.core.$strip>;
29
- execute: ({ task, summary, report }: {
30
- task: string;
31
- summary: string;
32
- report?: string;
33
- }) => Promise<{
34
- error: string;
35
- completed?: undefined;
36
- task?: undefined;
37
- summary?: undefined;
38
- message?: undefined;
39
- } | {
40
- completed: boolean;
41
- task: string;
42
- summary: string;
43
- message: string;
44
- error?: undefined;
45
- }>;
46
- };
47
- hive_exec_abort: {
48
- description: string;
49
- parameters: z.ZodObject<{
50
- task: z.ZodString;
51
- }, z.core.$strip>;
52
- execute: ({ task }: {
53
- task: string;
54
- }) => Promise<{
55
- error: string;
56
- aborted?: undefined;
57
- task?: undefined;
58
- message?: undefined;
59
- } | {
60
- aborted: boolean;
61
- task: string;
62
- message: string;
63
- error?: undefined;
64
- }>;
65
- };
66
- };
@@ -1,125 +0,0 @@
1
- import * as path from 'path';
2
- import { z } from 'zod';
3
- import { TaskService } from '../services/taskService.js';
4
- import { FeatureService } from '../services/featureService.js';
5
- import { WorktreeService } from '../services/worktreeService';
6
- import { detectContext } from '../utils/detection.js';
7
- export function createExecTools(projectRoot) {
8
- const taskService = new TaskService(projectRoot);
9
- const featureService = new FeatureService(projectRoot);
10
- const worktreeService = new WorktreeService({
11
- baseDir: projectRoot,
12
- hiveDir: path.join(projectRoot, '.hive'),
13
- });
14
- const getActiveFeature = () => {
15
- const ctx = detectContext(projectRoot);
16
- return ctx?.feature || null;
17
- };
18
- return {
19
- hive_exec_start: {
20
- description: 'Create worktree and begin work on task',
21
- parameters: z.object({
22
- task: z.string().describe('Task folder name (e.g., "01-auth-service")'),
23
- }),
24
- execute: async ({ task }) => {
25
- const feature = getActiveFeature();
26
- if (!feature) {
27
- return { error: 'No active feature.' };
28
- }
29
- const featureData = featureService.get(feature);
30
- if (!featureData || featureData.status === 'planning') {
31
- return { error: 'Feature must be approved before starting execution.' };
32
- }
33
- const taskInfo = taskService.get(feature, task);
34
- if (!taskInfo) {
35
- return { error: `Task '${task}' not found` };
36
- }
37
- if (taskInfo.status === 'done') {
38
- return { error: `Task '${task}' is already completed` };
39
- }
40
- if (taskInfo.status === 'in_progress') {
41
- const existing = await worktreeService.get(feature, task);
42
- if (existing) {
43
- return {
44
- worktreePath: existing.path,
45
- branch: existing.branch,
46
- message: `Task already in progress. Worktree at ${existing.path}`,
47
- };
48
- }
49
- }
50
- const worktree = await worktreeService.create(feature, task);
51
- taskService.update(feature, task, { status: 'in_progress' });
52
- return {
53
- worktreePath: worktree.path,
54
- branch: worktree.branch,
55
- message: `Worktree created at ${worktree.path}. Work on branch ${worktree.branch}.`,
56
- };
57
- },
58
- },
59
- hive_exec_complete: {
60
- description: 'Complete task: apply changes, write report',
61
- parameters: z.object({
62
- task: z.string().describe('Task folder name'),
63
- summary: z.string().describe('Summary of what was done'),
64
- report: z.string().optional().describe('Detailed report (markdown). If not provided, summary is used.'),
65
- }),
66
- execute: async ({ task, summary, report }) => {
67
- const feature = getActiveFeature();
68
- if (!feature) {
69
- return { error: 'No active feature.' };
70
- }
71
- const taskInfo = taskService.get(feature, task);
72
- if (!taskInfo) {
73
- return { error: `Task '${task}' not found` };
74
- }
75
- if (taskInfo.status !== 'in_progress') {
76
- return { error: `Task '${task}' is not in progress (status: ${taskInfo.status})` };
77
- }
78
- const worktree = await worktreeService.get(feature, task);
79
- if (!worktree) {
80
- return { error: `No worktree found for task '${task}'` };
81
- }
82
- const diff = await worktreeService.getDiff(feature, task);
83
- if (diff) {
84
- await worktreeService.applyDiff(feature, task);
85
- }
86
- const reportContent = report || `# ${task}\n\n## Summary\n\n${summary}\n`;
87
- taskService.writeReport(feature, task, reportContent);
88
- taskService.update(feature, task, { status: 'done', summary });
89
- await worktreeService.remove(feature, task);
90
- return {
91
- completed: true,
92
- task,
93
- summary,
94
- message: `Task '${task}' completed. Changes applied to main branch.`,
95
- };
96
- },
97
- },
98
- hive_exec_abort: {
99
- description: 'Abort task: discard changes, reset status',
100
- parameters: z.object({
101
- task: z.string().describe('Task folder name'),
102
- }),
103
- execute: async ({ task }) => {
104
- const feature = getActiveFeature();
105
- if (!feature) {
106
- return { error: 'No active feature.' };
107
- }
108
- const taskInfo = taskService.get(feature, task);
109
- if (!taskInfo) {
110
- return { error: `Task '${task}' not found` };
111
- }
112
- if (taskInfo.status !== 'in_progress') {
113
- return { error: `Task '${task}' is not in progress` };
114
- }
115
- await worktreeService.remove(feature, task);
116
- taskService.update(feature, task, { status: 'pending' });
117
- return {
118
- aborted: true,
119
- task,
120
- message: `Task '${task}' aborted. Worktree removed, status reset to pending.`,
121
- };
122
- },
123
- },
124
- };
125
- }
@@ -1,60 +0,0 @@
1
- import { z } from 'zod';
2
- export declare function createFeatureTools(projectRoot: string): {
3
- hive_feature_create: {
4
- description: string;
5
- parameters: z.ZodObject<{
6
- name: z.ZodString;
7
- ticket: z.ZodOptional<z.ZodString>;
8
- }, z.core.$strip>;
9
- execute: ({ name, ticket }: {
10
- name: string;
11
- ticket?: string;
12
- }) => Promise<{
13
- name: string;
14
- status: import("../types.js").FeatureStatusType;
15
- path: string;
16
- message: string;
17
- }>;
18
- };
19
- hive_feature_list: {
20
- description: string;
21
- parameters: z.ZodObject<{}, z.core.$strip>;
22
- execute: () => Promise<{
23
- features: {
24
- name: string;
25
- status: string;
26
- taskCount: number;
27
- isActive: boolean;
28
- }[];
29
- active: string | null;
30
- }>;
31
- };
32
- hive_feature_complete: {
33
- description: string;
34
- parameters: z.ZodObject<{
35
- _placeholder: z.ZodBoolean;
36
- name: z.ZodOptional<z.ZodString>;
37
- }, z.core.$strip>;
38
- execute: ({ name }: {
39
- name?: string;
40
- }) => Promise<{
41
- error: string;
42
- pendingTasks?: undefined;
43
- completed?: undefined;
44
- name?: undefined;
45
- message?: undefined;
46
- } | {
47
- error: string;
48
- pendingTasks: string[];
49
- completed?: undefined;
50
- name?: undefined;
51
- message?: undefined;
52
- } | {
53
- completed: boolean;
54
- name: string;
55
- message: string;
56
- error?: undefined;
57
- pendingTasks?: undefined;
58
- }>;
59
- };
60
- };
@@ -1,73 +0,0 @@
1
- import { z } from 'zod';
2
- import { FeatureService } from '../services/featureService.js';
3
- import { detectContext } from '../utils/detection.js';
4
- export function createFeatureTools(projectRoot) {
5
- const featureService = new FeatureService(projectRoot);
6
- const getActiveFeature = () => {
7
- const ctx = detectContext(projectRoot);
8
- return ctx?.feature || null;
9
- };
10
- return {
11
- hive_feature_create: {
12
- description: 'Create a new feature and set it as active.',
13
- parameters: z.object({
14
- name: z.string().describe('Feature name (will be used as folder name)'),
15
- ticket: z.string().optional().describe('Ticket/issue reference'),
16
- }),
17
- execute: async ({ name, ticket }) => {
18
- const feature = featureService.create(name, ticket);
19
- return {
20
- name: feature.name,
21
- status: feature.status,
22
- path: `.hive/features/${name}`,
23
- message: `Feature '${name}' created and set as active. Write a plan with hive_plan_write.`,
24
- };
25
- },
26
- },
27
- hive_feature_list: {
28
- description: 'List all features.',
29
- parameters: z.object({}),
30
- execute: async () => {
31
- const features = featureService.list();
32
- const active = getActiveFeature();
33
- const details = features.map(name => {
34
- const info = featureService.getInfo(name);
35
- return {
36
- name,
37
- status: info?.status || 'unknown',
38
- taskCount: info?.tasks.length || 0,
39
- isActive: name === active,
40
- };
41
- });
42
- return { features: details, active };
43
- },
44
- },
45
- hive_feature_complete: {
46
- description: 'Mark feature as completed (irreversible)',
47
- parameters: z.object({
48
- _placeholder: z.boolean().describe('Placeholder. Always pass true.'),
49
- name: z.string().optional(),
50
- }),
51
- execute: async ({ name }) => {
52
- const feature = name || getActiveFeature();
53
- if (!feature) {
54
- return { error: 'No active feature.' };
55
- }
56
- const info = featureService.getInfo(feature);
57
- const pendingTasks = info?.tasks.filter((t) => t.status === 'pending' || t.status === 'in_progress') || [];
58
- if (pendingTasks.length > 0) {
59
- return {
60
- error: `Cannot complete: ${pendingTasks.length} task(s) still pending or in progress`,
61
- pendingTasks: pendingTasks.map((t) => t.folder),
62
- };
63
- }
64
- featureService.complete(feature);
65
- return {
66
- completed: true,
67
- name: feature,
68
- message: `Feature '${feature}' marked as completed.`,
69
- };
70
- },
71
- },
72
- };
73
- }
@@ -1,47 +0,0 @@
1
- import { z } from 'zod';
2
- export declare function createPlanTools(projectRoot: string): {
3
- hive_plan_write: {
4
- description: string;
5
- parameters: z.ZodObject<{
6
- content: z.ZodString;
7
- }, z.core.$strip>;
8
- execute: ({ content }: {
9
- content: string;
10
- }) => Promise<{
11
- error: string;
12
- path?: undefined;
13
- message?: undefined;
14
- } | {
15
- path: string;
16
- message: string;
17
- error?: undefined;
18
- }>;
19
- };
20
- hive_plan_read: {
21
- description: string;
22
- parameters: z.ZodObject<{}, z.core.$strip>;
23
- execute: () => Promise<import("../types.js").PlanReadResult | {
24
- error: string;
25
- }>;
26
- };
27
- hive_plan_approve: {
28
- description: string;
29
- parameters: z.ZodObject<{}, z.core.$strip>;
30
- execute: () => Promise<{
31
- error: string;
32
- comments?: undefined;
33
- approved?: undefined;
34
- message?: undefined;
35
- } | {
36
- error: string;
37
- comments: import("../types.js").PlanComment[];
38
- approved?: undefined;
39
- message?: undefined;
40
- } | {
41
- approved: boolean;
42
- message: string;
43
- error?: undefined;
44
- comments?: undefined;
45
- }>;
46
- };
47
- };
@@ -1,65 +0,0 @@
1
- import { z } from 'zod';
2
- import { PlanService } from '../services/planService.js';
3
- import { FeatureService } from '../services/featureService.js';
4
- import { detectContext } from '../utils/detection.js';
5
- export function createPlanTools(projectRoot) {
6
- const planService = new PlanService(projectRoot);
7
- const featureService = new FeatureService(projectRoot);
8
- const getActiveFeature = () => {
9
- const ctx = detectContext(projectRoot);
10
- return ctx?.feature || null;
11
- };
12
- return {
13
- hive_plan_write: {
14
- description: 'Write plan.md (clears existing comments)',
15
- parameters: z.object({
16
- content: z.string().describe('The markdown content for the plan'),
17
- }),
18
- execute: async ({ content }) => {
19
- const feature = getActiveFeature();
20
- if (!feature) {
21
- return { error: 'No active feature. Create one with hive_feature_create first.' };
22
- }
23
- const path = planService.write(feature, content);
24
- return { path, message: `Plan written to ${path}. Comments cleared for fresh review.` };
25
- },
26
- },
27
- hive_plan_read: {
28
- description: 'Read plan.md and user comments',
29
- parameters: z.object({}),
30
- execute: async () => {
31
- const feature = getActiveFeature();
32
- if (!feature) {
33
- return { error: 'No active feature.' };
34
- }
35
- const result = planService.read(feature);
36
- if (!result) {
37
- return { error: `No plan.md found for feature '${feature}'` };
38
- }
39
- return result;
40
- },
41
- },
42
- hive_plan_approve: {
43
- description: 'Approve plan for execution',
44
- parameters: z.object({}),
45
- execute: async () => {
46
- const feature = getActiveFeature();
47
- if (!feature) {
48
- return { error: 'No active feature.' };
49
- }
50
- const comments = planService.getComments(feature);
51
- if (comments.length > 0) {
52
- return {
53
- error: `Cannot approve: ${comments.length} unresolved comment(s). Address comments and rewrite plan first.`,
54
- comments,
55
- };
56
- }
57
- planService.approve(feature);
58
- return {
59
- approved: true,
60
- message: 'Plan approved. Run hive_tasks_sync to generate tasks from the plan.',
61
- };
62
- },
63
- },
64
- };
65
- }
@@ -1,35 +0,0 @@
1
- import { z } from 'zod';
2
- export declare function createSessionTools(projectRoot: string): {
3
- hive_session_open: {
4
- description: string;
5
- parameters: z.ZodObject<{
6
- feature: z.ZodOptional<z.ZodString>;
7
- task: z.ZodOptional<z.ZodString>;
8
- }, z.core.$strip>;
9
- execute: ({ feature, task }: {
10
- feature?: string;
11
- task?: string;
12
- }, toolContext: unknown) => Promise<Record<string, unknown>>;
13
- };
14
- hive_session_list: {
15
- description: string;
16
- parameters: z.ZodObject<{}, z.core.$strip>;
17
- execute: () => Promise<{
18
- error: string;
19
- feature?: undefined;
20
- master?: undefined;
21
- sessions?: undefined;
22
- } | {
23
- feature: string;
24
- master: string | undefined;
25
- sessions: {
26
- sessionId: string;
27
- taskFolder: string | undefined;
28
- startedAt: string;
29
- lastActiveAt: string;
30
- isMaster: boolean;
31
- }[];
32
- error?: undefined;
33
- }>;
34
- };
35
- };