taskode 0.4.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.
- package/README.md +398 -0
- package/WORKFLOW.md +53 -0
- package/bin/taskode.js +7 -0
- package/package.json +30 -0
- package/public/app.js +1110 -0
- package/public/index.html +101 -0
- package/public/styles.css +821 -0
- package/src/app-server.js +555 -0
- package/src/auth.js +13 -0
- package/src/cli.js +176 -0
- package/src/orchestrator.js +655 -0
- package/src/path-safety.js +80 -0
- package/src/policy.js +23 -0
- package/src/review.js +197 -0
- package/src/runner.js +133 -0
- package/src/server.js +168 -0
- package/src/ssh.js +82 -0
- package/src/store.js +355 -0
- package/src/tracker/github.js +143 -0
- package/src/tracker/index.js +71 -0
- package/src/tracker/linear.js +229 -0
- package/src/tracker/local.js +75 -0
- package/src/workflow-store.js +77 -0
- package/src/workflow.js +339 -0
- package/src/workspace.js +291 -0
package/src/cli.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { TaskodeStore } from './store.js';
|
|
4
|
+
import { createServer } from './server.js';
|
|
5
|
+
import { WorkflowStore } from './workflow-store.js';
|
|
6
|
+
import { createTracker } from './tracker/index.js';
|
|
7
|
+
import { WorkspaceManager } from './workspace.js';
|
|
8
|
+
import { AgentRunner } from './runner.js';
|
|
9
|
+
import { Orchestrator } from './orchestrator.js';
|
|
10
|
+
|
|
11
|
+
export async function runCli(args) {
|
|
12
|
+
const command = args[0] || 'start';
|
|
13
|
+
|
|
14
|
+
if (command === 'init') {
|
|
15
|
+
runInit(process.cwd());
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (command === 'doctor') {
|
|
20
|
+
runDoctor();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const options = parseOptions(args);
|
|
25
|
+
const workflowPath = path.resolve(process.cwd(), options.workflowPath || 'WORKFLOW.md');
|
|
26
|
+
const workflowRuntime = new WorkflowStore({ workflowPath, cliOptions: options });
|
|
27
|
+
const config = workflowRuntime.getConfig();
|
|
28
|
+
|
|
29
|
+
const dataDir = path.join(process.cwd(), '.taskode');
|
|
30
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
31
|
+
|
|
32
|
+
const store = new TaskodeStore(path.join(dataDir, 'data.json'));
|
|
33
|
+
const tracker = createTracker({ store, config });
|
|
34
|
+
const workspaceManager = new WorkspaceManager({ config, store });
|
|
35
|
+
const agentRunner = new AgentRunner({ config, store });
|
|
36
|
+
const orchestrator = new Orchestrator({ config, tracker, workspaceManager, agentRunner, store, workflowRuntime });
|
|
37
|
+
|
|
38
|
+
ensureSeedTaskIfEmpty(store, config);
|
|
39
|
+
orchestrator.start();
|
|
40
|
+
|
|
41
|
+
const app = createServer({ store, orchestrator, tracker, config });
|
|
42
|
+
app.listen(config.server.port, config.server.host, () => {
|
|
43
|
+
console.log(`[taskode] workflow: ${config.workflowPath}`);
|
|
44
|
+
console.log(`[taskode] tracker: ${config.tracker.kind}`);
|
|
45
|
+
console.log(`[taskode] codex mode: ${config.codex.mode}`);
|
|
46
|
+
console.log(`[taskode] auth: ${config.auth.token ? 'enabled' : 'disabled'}`);
|
|
47
|
+
console.log(`[taskode] web: http://${config.server.host}:${config.server.port}`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
process.on('SIGINT', () => {
|
|
51
|
+
orchestrator.stop();
|
|
52
|
+
process.exit(0);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ensureSeedTaskIfEmpty(store, config) {
|
|
57
|
+
if (config.tracker.kind !== 'local') return;
|
|
58
|
+
if (store.listTasks().length > 0) return;
|
|
59
|
+
|
|
60
|
+
store.createTask({
|
|
61
|
+
title: 'Welcome to Taskode',
|
|
62
|
+
description: 'Create tasks from the web UI. Approve reviewed runs to apply workspace changes back to the project.',
|
|
63
|
+
type: 'todo',
|
|
64
|
+
priority: 'medium'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function runInit(cwd) {
|
|
69
|
+
const workflowPath = path.join(cwd, 'WORKFLOW.md');
|
|
70
|
+
if (fs.existsSync(workflowPath)) {
|
|
71
|
+
console.log('[taskode] WORKFLOW.md already exists');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fs.writeFileSync(
|
|
76
|
+
workflowPath,
|
|
77
|
+
[
|
|
78
|
+
'---',
|
|
79
|
+
'tracker:',
|
|
80
|
+
' kind: local',
|
|
81
|
+
'workspace:',
|
|
82
|
+
' root: ./.taskode/workspaces',
|
|
83
|
+
' seed_from_project: true',
|
|
84
|
+
' copy_ignore: [".git", ".taskode", "node_modules"]',
|
|
85
|
+
'agent:',
|
|
86
|
+
' poll_interval_ms: 3000',
|
|
87
|
+
' max_concurrent_agents: 2',
|
|
88
|
+
' max_retry_attempts: 5',
|
|
89
|
+
' max_retry_backoff_ms: 60000',
|
|
90
|
+
' max_concurrent_agents_by_state: {}',
|
|
91
|
+
' max_turns: 20',
|
|
92
|
+
'worker:',
|
|
93
|
+
' ssh_hosts: []',
|
|
94
|
+
' max_concurrent_agents_per_host:',
|
|
95
|
+
'codex:',
|
|
96
|
+
' mode: shell',
|
|
97
|
+
' command: echo "simulated codex run"',
|
|
98
|
+
' timeout_ms: 120000',
|
|
99
|
+
' read_timeout_ms: 5000',
|
|
100
|
+
' turn_timeout_ms: 3600000',
|
|
101
|
+
' stall_timeout_ms: 300000',
|
|
102
|
+
' approval_policy:',
|
|
103
|
+
' reject:',
|
|
104
|
+
' sandbox_approval: true',
|
|
105
|
+
' rules: true',
|
|
106
|
+
' mcp_elicitations: true',
|
|
107
|
+
' thread_sandbox: workspace-write',
|
|
108
|
+
'hooks:',
|
|
109
|
+
' after_create:',
|
|
110
|
+
' before_run:',
|
|
111
|
+
' after_run:',
|
|
112
|
+
' before_remove:',
|
|
113
|
+
' timeout_ms: 60000',
|
|
114
|
+
'policy:',
|
|
115
|
+
' allow_commands: ["*"]',
|
|
116
|
+
' deny_commands: []',
|
|
117
|
+
'review:',
|
|
118
|
+
' auto_cleanup_approved: true',
|
|
119
|
+
'auth:',
|
|
120
|
+
' token: $TASKODE_API_TOKEN',
|
|
121
|
+
'server:',
|
|
122
|
+
' host: 127.0.0.1',
|
|
123
|
+
' port: 4317',
|
|
124
|
+
'---',
|
|
125
|
+
'',
|
|
126
|
+
'You are working on issue {{ issue.identifier }}.',
|
|
127
|
+
'',
|
|
128
|
+
'Title: {{ issue.title }}',
|
|
129
|
+
'Body: {{ issue.description }}',
|
|
130
|
+
'',
|
|
131
|
+
'Deliverables:',
|
|
132
|
+
'1) Plan',
|
|
133
|
+
'2) Implementation',
|
|
134
|
+
'3) Tests',
|
|
135
|
+
'4) Summary',
|
|
136
|
+
''
|
|
137
|
+
].join('\n'),
|
|
138
|
+
'utf8'
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
console.log('[taskode] created WORKFLOW.md');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function runDoctor() {
|
|
145
|
+
console.log(`[taskode] node: ${process.version}`);
|
|
146
|
+
console.log(`[taskode] LINEAR_API_KEY: ${process.env.LINEAR_API_KEY ? 'set' : 'not set'}`);
|
|
147
|
+
console.log(`[taskode] GITHUB_TOKEN: ${process.env.GITHUB_TOKEN ? 'set' : 'not set'}`);
|
|
148
|
+
console.log(`[taskode] TASKODE_API_TOKEN: ${process.env.TASKODE_API_TOKEN ? 'set' : 'not set'}`);
|
|
149
|
+
console.log('[taskode] doctor check ok');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function parseOptions(args) {
|
|
153
|
+
const options = { workflowPath: null, port: null, logsRoot: null };
|
|
154
|
+
|
|
155
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
156
|
+
const value = args[index];
|
|
157
|
+
|
|
158
|
+
if (value === '--port') {
|
|
159
|
+
options.port = Number(args[index + 1]);
|
|
160
|
+
index += 1;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (value === '--logs-root') {
|
|
165
|
+
options.logsRoot = args[index + 1];
|
|
166
|
+
index += 1;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!value.startsWith('-') && value !== 'start' && !options.workflowPath) {
|
|
171
|
+
options.workflowPath = value;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return options;
|
|
176
|
+
}
|