@alvarolorentedev/opencode-taskfeed 0.0.0-stage → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +431 -2
- package/docs/architecture.md +123 -0
- package/docs/configuration.md +123 -0
- package/docs/development.md +312 -0
- package/docs/integrations.md +84 -0
- package/docs/operations.md +136 -0
- package/docs/releases/v0.1.0-alpha.1.md +164 -0
- package/docs/security.md +120 -0
- package/examples/README.md +7 -0
- package/examples/approvals/README.md +27 -0
- package/examples/flowgraph/config.yaml +28 -0
- package/examples/flowgraph/opencode.jsonc +14 -0
- package/examples/headless/README.md +25 -0
- package/examples/headless/config.yaml +21 -0
- package/examples/native-agent/config.yaml +31 -0
- package/examples/native-agent/opencode.jsonc +10 -0
- package/examples/playground/README.md +61 -0
- package/examples/playground/config.yaml +40 -0
- package/examples/playground/opencode.jsonc +5 -0
- package/package.json +89 -4
- package/src/config/load.ts +122 -0
- package/src/config/repository.ts +72 -0
- package/src/config/schema.ts +215 -0
- package/src/core/approval.ts +190 -0
- package/src/core/comments.ts +175 -0
- package/src/core/index.ts +5 -0
- package/src/core/ports.ts +185 -0
- package/src/core/state.ts +186 -0
- package/src/core/types.ts +430 -0
- package/src/executors/flowgraph/client.ts +27 -0
- package/src/executors/flowgraph/executor.ts +593 -0
- package/src/executors/flowgraph/lazy.ts +77 -0
- package/src/executors/flowgraph/rpc.ts +145 -0
- package/src/executors/flowgraph/worker.ts +538 -0
- package/src/executors/native/bridge.ts +421 -0
- package/src/executors/native/executor.ts +295 -0
- package/src/executors/native/prompt.ts +57 -0
- package/src/executors/native/trust.ts +105 -0
- package/src/index.ts +116 -0
- package/src/rpc.ts +75 -0
- package/src/runtime/backends.ts +27 -0
- package/src/runtime/engine.ts +2345 -0
- package/src/runtime/server-backends.ts +136 -0
- package/src/runtime/service.ts +276 -0
- package/src/sources/github/client.ts +98 -0
- package/src/sources/github/source.ts +490 -0
- package/src/storage/capacity.ts +223 -0
- package/src/storage/jobs.ts +249 -0
- package/src/storage/locks.ts +342 -0
- package/src/tui.tsx +399 -0
- package/src/util/ids.ts +18 -0
- package/src/util/logger.ts +52 -0
- package/src/util/process.ts +119 -0
- package/src/util/redact.ts +28 -0
- package/src/version.ts +2 -0
- package/src/workspaces/native.ts +162 -0
- package/src/workspaces/publication.ts +477 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
|
|
3
|
+
source:
|
|
4
|
+
type: github
|
|
5
|
+
repository: auto
|
|
6
|
+
labels:
|
|
7
|
+
- agent-ready
|
|
8
|
+
|
|
9
|
+
execution:
|
|
10
|
+
type: agent
|
|
11
|
+
name: build
|
|
12
|
+
|
|
13
|
+
scheduler:
|
|
14
|
+
# Keep automation off until the repository and identities are verified.
|
|
15
|
+
enabled: false
|
|
16
|
+
poll_interval_seconds: 60
|
|
17
|
+
concurrency: 1
|
|
18
|
+
|
|
19
|
+
workspace:
|
|
20
|
+
isolation: worktree
|
|
21
|
+
|
|
22
|
+
limits:
|
|
23
|
+
max_attempts: 2
|
|
24
|
+
max_feedback_iterations: 3
|
|
25
|
+
execution_timeout_seconds: 14400
|
|
26
|
+
retry_backoff_seconds: 30
|
|
27
|
+
|
|
28
|
+
approvals:
|
|
29
|
+
provider: github
|
|
30
|
+
authorized_users:
|
|
31
|
+
- your-github-login
|
|
32
|
+
enqueue_users:
|
|
33
|
+
- your-github-login
|
|
34
|
+
|
|
35
|
+
publication:
|
|
36
|
+
# Draft PR publication is opt-in.
|
|
37
|
+
enabled: false
|
|
38
|
+
remote: origin
|
|
39
|
+
draft_pull_request: true
|
|
40
|
+
branch_prefix: taskfeed/
|
package/package.json
CHANGED
|
@@ -1,6 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alvarolorentedev/opencode-taskfeed",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Turn your backlog into agent work. Native GitHub automation for OpenCode.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.ts",
|
|
9
|
+
"./tui": "./src/tui.tsx",
|
|
10
|
+
"./rpc": "./src/rpc.ts",
|
|
11
|
+
"./server": "./src/index.ts",
|
|
12
|
+
"./core": "./src/core/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"src",
|
|
16
|
+
"docs",
|
|
17
|
+
"examples",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"package.json"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"build": "bun run check:version && bun run typecheck",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest",
|
|
27
|
+
"test:unit": "vitest run tests/unit",
|
|
28
|
+
"test:integration": "vitest run tests/integration",
|
|
29
|
+
"test:real": "vitest run tests/real",
|
|
30
|
+
"test:real:native": "RUN_REAL_OPENCODE=1 vitest run tests/real/opencode.test.ts -t 'native agent|draft PR'",
|
|
31
|
+
"test:real:flowgraph": "RUN_REAL_OPENCODE=1 vitest run tests/real/opencode.test.ts -t 'Flowgraph'",
|
|
32
|
+
"test:real:github": "vitest run tests/real/github.test.ts",
|
|
33
|
+
"check:version": "bun run scripts/release.ts check-version",
|
|
34
|
+
"check": "bun run check:version && bun run typecheck && bun run test",
|
|
35
|
+
"verify:pack": "bun run scripts/verify-pack.ts",
|
|
36
|
+
"release:info": "bun run scripts/release.ts info",
|
|
37
|
+
"release:publish": "bun run scripts/release.ts publish",
|
|
38
|
+
"prepublishOnly": "bun run check && bun run verify:pack"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"bun": ">=1.2.0",
|
|
42
|
+
"node": ">=20.19.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@opencode/client": "2.3.2",
|
|
46
|
+
"@opencode/plugin": "2.3.2",
|
|
47
|
+
"proper-lockfile": "^4.1.2",
|
|
48
|
+
"yaml": "^2.8.1",
|
|
49
|
+
"zod": "^4.1.12"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@opentui/core": ">=0.8.0",
|
|
53
|
+
"@opentui/solid": ">=0.8.0",
|
|
54
|
+
"solid-js": ">=1.9.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@opentui/core": { "optional": true },
|
|
58
|
+
"@opentui/solid": { "optional": true },
|
|
59
|
+
"solid-js": { "optional": true }
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@opencode/theme": "2.3.2",
|
|
63
|
+
"@opentui/core": "0.8.0",
|
|
64
|
+
"@opentui/solid": "0.8.0",
|
|
65
|
+
"@types/node": "^22.10.0",
|
|
66
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
67
|
+
"solid-js": "1.9.17",
|
|
68
|
+
"typescript": "^5.7.2",
|
|
69
|
+
"vitest": "^4.1.12"
|
|
70
|
+
},
|
|
71
|
+
"keywords": [
|
|
72
|
+
"opencode",
|
|
73
|
+
"opencode-plugin",
|
|
74
|
+
"taskfeed",
|
|
75
|
+
"github",
|
|
76
|
+
"automation",
|
|
77
|
+
"flowgraph",
|
|
78
|
+
"agents"
|
|
79
|
+
],
|
|
80
|
+
"repository": {
|
|
81
|
+
"type": "git",
|
|
82
|
+
"url": "git+https://github.com/alvarolorentedev/opencode-taskfeed.git"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://github.com/alvarolorentedev/opencode-taskfeed#readme",
|
|
85
|
+
"bugs": {
|
|
86
|
+
"url": "https://github.com/alvarolorentedev/opencode-taskfeed/issues"
|
|
87
|
+
},
|
|
88
|
+
"publishConfig": {
|
|
89
|
+
"access": "public"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { lstat, readFile } from "node:fs/promises"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import YAML from "yaml"
|
|
4
|
+
import { ZodError } from "zod"
|
|
5
|
+
import type { CommandRunner } from "../util/process.js"
|
|
6
|
+
import { stableHash } from "../util/ids.js"
|
|
7
|
+
import { discoverRepository } from "./repository.js"
|
|
8
|
+
import { TaskfeedConfigSchema, type TaskfeedConfig } from "./schema.js"
|
|
9
|
+
|
|
10
|
+
export const CONFIG_RELATIVE_PATH = ".taskfeed/config.yaml"
|
|
11
|
+
const MAX_CONFIG_BYTES = 256 * 1024
|
|
12
|
+
|
|
13
|
+
export interface LoadedConfig {
|
|
14
|
+
readonly status: "valid"
|
|
15
|
+
readonly path: string
|
|
16
|
+
readonly canonicalDirectory: string
|
|
17
|
+
readonly contentHash: string
|
|
18
|
+
readonly repository: string
|
|
19
|
+
readonly config: TaskfeedConfig
|
|
20
|
+
readonly enqueueUsers: readonly string[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface MissingConfig {
|
|
24
|
+
readonly status: "missing"
|
|
25
|
+
readonly path: string
|
|
26
|
+
readonly canonicalDirectory: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface InvalidConfig {
|
|
30
|
+
readonly status: "invalid"
|
|
31
|
+
readonly path: string
|
|
32
|
+
readonly canonicalDirectory: string
|
|
33
|
+
readonly error: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ConfigState = LoadedConfig | MissingConfig | InvalidConfig
|
|
37
|
+
|
|
38
|
+
export function formatConfigError(error: unknown): string {
|
|
39
|
+
if (error instanceof ZodError) {
|
|
40
|
+
return error.issues
|
|
41
|
+
.map((issue) => `${issue.path.length === 0 ? "config" : issue.path.join(".")}: ${issue.message}`)
|
|
42
|
+
.join("; ")
|
|
43
|
+
}
|
|
44
|
+
return error instanceof Error ? error.message : String(error)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function loadConfig(input: {
|
|
48
|
+
canonicalDirectory: string
|
|
49
|
+
runner: CommandRunner
|
|
50
|
+
}): Promise<ConfigState> {
|
|
51
|
+
const file = path.join(input.canonicalDirectory, CONFIG_RELATIVE_PATH)
|
|
52
|
+
let info
|
|
53
|
+
try {
|
|
54
|
+
info = await lstat(file)
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
57
|
+
return { status: "missing", path: file, canonicalDirectory: input.canonicalDirectory }
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
status: "invalid",
|
|
61
|
+
path: file,
|
|
62
|
+
canonicalDirectory: input.canonicalDirectory,
|
|
63
|
+
error: `cannot inspect configuration: ${error instanceof Error ? error.message : String(error)}`,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (info.isSymbolicLink() || !info.isFile()) {
|
|
67
|
+
return {
|
|
68
|
+
status: "invalid",
|
|
69
|
+
path: file,
|
|
70
|
+
canonicalDirectory: input.canonicalDirectory,
|
|
71
|
+
error: "configuration must be a regular file, not a symlink",
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (info.size > MAX_CONFIG_BYTES) {
|
|
75
|
+
return {
|
|
76
|
+
status: "invalid",
|
|
77
|
+
path: file,
|
|
78
|
+
canonicalDirectory: input.canonicalDirectory,
|
|
79
|
+
error: `configuration exceeds ${MAX_CONFIG_BYTES} bytes`,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let source: string
|
|
84
|
+
try {
|
|
85
|
+
source = await readFile(file, "utf8")
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return {
|
|
88
|
+
status: "invalid",
|
|
89
|
+
path: file,
|
|
90
|
+
canonicalDirectory: input.canonicalDirectory,
|
|
91
|
+
error: `cannot read configuration: ${error instanceof Error ? error.message : String(error)}`,
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const document = YAML.parse(source, { schema: "core" })
|
|
97
|
+
const config = TaskfeedConfigSchema.parse(document)
|
|
98
|
+
const repository = await discoverRepository(input.runner, input.canonicalDirectory, config.source.repository)
|
|
99
|
+
return {
|
|
100
|
+
status: "valid",
|
|
101
|
+
path: file,
|
|
102
|
+
canonicalDirectory: input.canonicalDirectory,
|
|
103
|
+
contentHash: stableHash(source, 64),
|
|
104
|
+
repository,
|
|
105
|
+
config,
|
|
106
|
+
enqueueUsers: (config.approvals.enqueue_users ?? config.approvals.authorized_users).map((value) =>
|
|
107
|
+
value.toLowerCase(),
|
|
108
|
+
),
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
return {
|
|
112
|
+
status: "invalid",
|
|
113
|
+
path: file,
|
|
114
|
+
canonicalDirectory: input.canonicalDirectory,
|
|
115
|
+
error: formatConfigError(error),
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function isEnabled(state: ConfigState): boolean {
|
|
121
|
+
return state.status === "valid" && state.config.scheduler.enabled
|
|
122
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { CommandRunner } from "../util/process.js"
|
|
2
|
+
|
|
3
|
+
const REPOSITORY = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u
|
|
4
|
+
|
|
5
|
+
export class RepositoryResolutionError extends Error {
|
|
6
|
+
constructor(message: string) {
|
|
7
|
+
super(message)
|
|
8
|
+
this.name = "RepositoryResolutionError"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Parses only GitHub remotes and never retains embedded credentials. */
|
|
13
|
+
export function parseGitHubRemote(remote: string): string | undefined {
|
|
14
|
+
const value = remote.trim()
|
|
15
|
+
let host: string | undefined
|
|
16
|
+
let pathname: string | undefined
|
|
17
|
+
|
|
18
|
+
const scp = /^[^@\s]+@([^:\s]+):(.+)$/u.exec(value)
|
|
19
|
+
if (scp) {
|
|
20
|
+
host = scp[1]
|
|
21
|
+
pathname = scp[2]
|
|
22
|
+
} else {
|
|
23
|
+
try {
|
|
24
|
+
const url = new URL(value)
|
|
25
|
+
host = url.hostname
|
|
26
|
+
pathname = decodeURIComponent(url.pathname)
|
|
27
|
+
} catch {
|
|
28
|
+
if (/^github\.com\//iu.test(value)) {
|
|
29
|
+
host = "github.com"
|
|
30
|
+
pathname = value.slice("github.com/".length)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!host || !pathname || host.toLowerCase() !== "github.com") return undefined
|
|
36
|
+
const normalized = pathname.replace(/^\/+/u, "").replace(/\.git$/u, "").replace(/\/+$/u, "")
|
|
37
|
+
return REPOSITORY.test(normalized) ? normalized : undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function discoverRepository(
|
|
41
|
+
runner: CommandRunner,
|
|
42
|
+
canonicalDirectory: string,
|
|
43
|
+
configured: string | "auto",
|
|
44
|
+
signal?: AbortSignal,
|
|
45
|
+
): Promise<string> {
|
|
46
|
+
if (configured !== "auto") return configured
|
|
47
|
+
const remotes = await runner.run("git", ["remote"], { cwd: canonicalDirectory, timeoutMs: 10_000 })
|
|
48
|
+
if (remotes.exitCode !== 0) {
|
|
49
|
+
throw new RepositoryResolutionError("could not list Git remotes; set source.repository explicitly")
|
|
50
|
+
}
|
|
51
|
+
const names = remotes.stdout.split(/\r?\n/u).map((value) => value.trim()).filter(Boolean)
|
|
52
|
+
const preferred = names.includes("origin") ? ["origin"] : names
|
|
53
|
+
if (preferred.length === 0) {
|
|
54
|
+
throw new RepositoryResolutionError("no Git remotes found; set source.repository explicitly")
|
|
55
|
+
}
|
|
56
|
+
const found = new Map<string, string>()
|
|
57
|
+
for (const name of preferred) {
|
|
58
|
+
if (signal?.aborted) throw new Error("repository discovery cancelled")
|
|
59
|
+
const result = await runner.run("git", ["remote", "get-url", name], { cwd: canonicalDirectory, timeoutMs: 10_000 })
|
|
60
|
+
if (result.exitCode !== 0) continue
|
|
61
|
+
const repository = parseGitHubRemote(result.stdout)
|
|
62
|
+
if (repository) found.set(name, repository)
|
|
63
|
+
}
|
|
64
|
+
const unique = [...new Set(found.values())]
|
|
65
|
+
if (unique.length === 1) return unique[0]!
|
|
66
|
+
if (unique.length === 0) {
|
|
67
|
+
throw new RepositoryResolutionError("no GitHub remote found; set source.repository explicitly")
|
|
68
|
+
}
|
|
69
|
+
throw new RepositoryResolutionError(
|
|
70
|
+
"multiple GitHub remotes found; set source.repository explicitly to choose one",
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
const Login = z
|
|
4
|
+
.string()
|
|
5
|
+
.min(1)
|
|
6
|
+
.max(100)
|
|
7
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9-]*(?:\[bot\])?$/u, "must be a GitHub login")
|
|
8
|
+
|
|
9
|
+
const Repository = z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u, "must be owner/repository")
|
|
12
|
+
|
|
13
|
+
const Label = z.string().min(1).max(100).regex(/^[^\s]+$/u, "label names cannot contain whitespace")
|
|
14
|
+
|
|
15
|
+
const Ref = z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(200)
|
|
19
|
+
.regex(/^[A-Za-z0-9._/-]+$/u, "invalid Git ref")
|
|
20
|
+
.refine((value) => !value.startsWith("/") && !value.endsWith("/") && !value.includes(".."), "invalid Git ref")
|
|
21
|
+
|
|
22
|
+
const BranchPrefix = z
|
|
23
|
+
.string()
|
|
24
|
+
.min(1)
|
|
25
|
+
.max(80)
|
|
26
|
+
.regex(/^[A-Za-z0-9._/-]+$/u, "invalid branch prefix")
|
|
27
|
+
.refine((value) => !value.startsWith("/") && !value.includes(".."), "invalid branch prefix")
|
|
28
|
+
|
|
29
|
+
export const DEFAULT_PROTECTED_PATHS = [
|
|
30
|
+
".env",
|
|
31
|
+
".env.*",
|
|
32
|
+
"**/.env",
|
|
33
|
+
"**/.env.*",
|
|
34
|
+
"*.pem",
|
|
35
|
+
"**/*.pem",
|
|
36
|
+
"*.key",
|
|
37
|
+
"**/*.key",
|
|
38
|
+
"*.p12",
|
|
39
|
+
"**/*.p12",
|
|
40
|
+
"*.pfx",
|
|
41
|
+
"**/*.pfx",
|
|
42
|
+
"id_rsa*",
|
|
43
|
+
"**/id_rsa*",
|
|
44
|
+
"id_ed25519*",
|
|
45
|
+
"**/id_ed25519*",
|
|
46
|
+
".npmrc",
|
|
47
|
+
"**/.npmrc",
|
|
48
|
+
".pypirc",
|
|
49
|
+
"**/.pypirc",
|
|
50
|
+
".aws/**",
|
|
51
|
+
"**/.aws/**",
|
|
52
|
+
".ssh/**",
|
|
53
|
+
"**/.ssh/**",
|
|
54
|
+
"**/credentials",
|
|
55
|
+
"**/credentials.json",
|
|
56
|
+
"**/*.crt",
|
|
57
|
+
"**/*.cer",
|
|
58
|
+
"**/*.der",
|
|
59
|
+
] as const
|
|
60
|
+
|
|
61
|
+
export const DEFAULT_GENERATED_ARTIFACTS = [
|
|
62
|
+
"**/node_modules/**",
|
|
63
|
+
"**/dist/**",
|
|
64
|
+
"**/coverage/**",
|
|
65
|
+
"**/*.tgz",
|
|
66
|
+
"**/*.tar.gz",
|
|
67
|
+
"**/*.zip",
|
|
68
|
+
"**/*.log",
|
|
69
|
+
] as const
|
|
70
|
+
|
|
71
|
+
export const StatusLabelsSchema = z
|
|
72
|
+
.object({
|
|
73
|
+
running: Label.default("agent-running"),
|
|
74
|
+
review: Label.default("agent-review"),
|
|
75
|
+
blocked: Label.default("agent-blocked"),
|
|
76
|
+
completed: Label.default("agent-completed"),
|
|
77
|
+
})
|
|
78
|
+
.strict()
|
|
79
|
+
|
|
80
|
+
export const TaskfeedConfigSchema = z
|
|
81
|
+
.object({
|
|
82
|
+
version: z.literal(1),
|
|
83
|
+
source: z
|
|
84
|
+
.object({
|
|
85
|
+
type: z.literal("github"),
|
|
86
|
+
repository: z.union([z.literal("auto"), Repository]).default("auto"),
|
|
87
|
+
labels: z.array(Label).min(1).max(10).default(["agent-ready"]),
|
|
88
|
+
status_labels: StatusLabelsSchema.default({
|
|
89
|
+
running: "agent-running",
|
|
90
|
+
review: "agent-review",
|
|
91
|
+
blocked: "agent-blocked",
|
|
92
|
+
completed: "agent-completed",
|
|
93
|
+
}),
|
|
94
|
+
})
|
|
95
|
+
.strict(),
|
|
96
|
+
execution: z.discriminatedUnion("type", [
|
|
97
|
+
z
|
|
98
|
+
.object({
|
|
99
|
+
type: z.literal("agent"),
|
|
100
|
+
name: z.string().min(1).max(100),
|
|
101
|
+
})
|
|
102
|
+
.strict(),
|
|
103
|
+
z
|
|
104
|
+
.object({
|
|
105
|
+
type: z.literal("workflow"),
|
|
106
|
+
name: z.string().min(1).max(100),
|
|
107
|
+
})
|
|
108
|
+
.strict(),
|
|
109
|
+
]),
|
|
110
|
+
scheduler: z
|
|
111
|
+
.object({
|
|
112
|
+
enabled: z.boolean().default(false),
|
|
113
|
+
poll_interval_seconds: z.number().int().min(5).max(3_600).default(60),
|
|
114
|
+
concurrency: z.number().int().min(1).max(16).default(1),
|
|
115
|
+
})
|
|
116
|
+
.strict()
|
|
117
|
+
.default({ enabled: false, poll_interval_seconds: 60, concurrency: 1 }),
|
|
118
|
+
workspace: z
|
|
119
|
+
.object({
|
|
120
|
+
isolation: z.literal("worktree").default("worktree"),
|
|
121
|
+
base_branch: Ref.optional(),
|
|
122
|
+
})
|
|
123
|
+
.strict()
|
|
124
|
+
.default({ isolation: "worktree" }),
|
|
125
|
+
limits: z
|
|
126
|
+
.object({
|
|
127
|
+
max_attempts: z.number().int().min(1).max(10).default(2),
|
|
128
|
+
max_feedback_iterations: z.number().int().min(1).max(20).default(3),
|
|
129
|
+
execution_timeout_seconds: z.number().int().min(60).max(7 * 24 * 60 * 60).default(4 * 60 * 60),
|
|
130
|
+
retry_backoff_seconds: z.number().int().min(1).max(3_600).default(30),
|
|
131
|
+
})
|
|
132
|
+
.strict()
|
|
133
|
+
.default({
|
|
134
|
+
max_attempts: 2,
|
|
135
|
+
max_feedback_iterations: 3,
|
|
136
|
+
execution_timeout_seconds: 4 * 60 * 60,
|
|
137
|
+
retry_backoff_seconds: 30,
|
|
138
|
+
}),
|
|
139
|
+
approvals: z
|
|
140
|
+
.object({
|
|
141
|
+
provider: z.literal("github").default("github"),
|
|
142
|
+
authorized_users: z.array(Login).max(100).default([]),
|
|
143
|
+
/** Who may apply the ready label. Defaults to authorized_users. */
|
|
144
|
+
enqueue_users: z.array(Login).max(100).optional(),
|
|
145
|
+
})
|
|
146
|
+
.strict()
|
|
147
|
+
.default({ provider: "github", authorized_users: [] }),
|
|
148
|
+
publication: z
|
|
149
|
+
.object({
|
|
150
|
+
enabled: z.boolean().default(false),
|
|
151
|
+
provider: z.literal("github").default("github"),
|
|
152
|
+
remote: z.string().min(1).max(100).regex(/^[A-Za-z0-9._-]+$/u).default("origin"),
|
|
153
|
+
base_branch: Ref.optional(),
|
|
154
|
+
draft_pull_request: z.literal(true).default(true),
|
|
155
|
+
branch_prefix: BranchPrefix.default("taskfeed/"),
|
|
156
|
+
protected_paths: z
|
|
157
|
+
.array(z.string().min(1).max(300))
|
|
158
|
+
.max(200)
|
|
159
|
+
.default([...DEFAULT_PROTECTED_PATHS]),
|
|
160
|
+
generated_artifacts: z
|
|
161
|
+
.array(z.string().min(1).max(300))
|
|
162
|
+
.max(200)
|
|
163
|
+
.default([...DEFAULT_GENERATED_ARTIFACTS]),
|
|
164
|
+
max_file_bytes: z.number().int().min(1_024).max(100 * 1024 * 1024).default(1_048_576),
|
|
165
|
+
})
|
|
166
|
+
.strict()
|
|
167
|
+
.default({
|
|
168
|
+
enabled: false,
|
|
169
|
+
provider: "github",
|
|
170
|
+
remote: "origin",
|
|
171
|
+
draft_pull_request: true,
|
|
172
|
+
branch_prefix: "taskfeed/",
|
|
173
|
+
protected_paths: [...DEFAULT_PROTECTED_PATHS],
|
|
174
|
+
generated_artifacts: [...DEFAULT_GENERATED_ARTIFACTS],
|
|
175
|
+
max_file_bytes: 1_048_576,
|
|
176
|
+
}),
|
|
177
|
+
})
|
|
178
|
+
.strict()
|
|
179
|
+
.superRefine((value, context) => {
|
|
180
|
+
const trigger = new Set(value.source.labels)
|
|
181
|
+
for (const [name, label] of Object.entries(value.source.status_labels)) {
|
|
182
|
+
if (trigger.has(label)) context.addIssue({ code: "custom", path: ["source", "status_labels", name], message: `status label "${label}" is also a trigger label` })
|
|
183
|
+
}
|
|
184
|
+
const statuses = Object.values(value.source.status_labels)
|
|
185
|
+
if (new Set(statuses).size !== statuses.length) {
|
|
186
|
+
context.addIssue({ code: "custom", path: ["source", "status_labels"], message: "status labels must be distinct" })
|
|
187
|
+
}
|
|
188
|
+
const enqueue = value.approvals.enqueue_users ?? value.approvals.authorized_users
|
|
189
|
+
if (enqueue.length === 0) {
|
|
190
|
+
context.addIssue({
|
|
191
|
+
code: "custom",
|
|
192
|
+
path: ["approvals", "enqueue_users"],
|
|
193
|
+
message: "configure at least one enqueue user; a ready label alone is never sufficient authorization",
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
if (value.execution.type === "agent" && value.approvals.authorized_users.length === 0) {
|
|
197
|
+
context.addIssue({
|
|
198
|
+
code: "custom",
|
|
199
|
+
path: ["approvals", "authorized_users"],
|
|
200
|
+
message: "native agent execution requires at least one authorized approval user",
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
if (value.publication.enabled && !value.publication.branch_prefix.endsWith("/")) {
|
|
204
|
+
context.addIssue({
|
|
205
|
+
code: "custom",
|
|
206
|
+
path: ["publication", "branch_prefix"],
|
|
207
|
+
message: "branch_prefix must end with /",
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
export type TaskfeedConfig = z.infer<typeof TaskfeedConfigSchema>
|
|
213
|
+
export type StatusLabels = z.infer<typeof StatusLabelsSchema>
|
|
214
|
+
export type ApprovalProviderConfig = TaskfeedConfig["approvals"]
|
|
215
|
+
export type PublicationConfig = TaskfeedConfig["publication"]
|