opencode-jobs 0.1.2 → 1.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.
- package/README.md +87 -26
- package/dist/cli.js +827 -63
- package/dist/index.d.ts +1 -1
- package/dist/index.js +302 -49
- package/dist/install.d.ts +3 -0
- package/dist/internals.d.ts +2 -1
- package/dist/job.d.ts +7 -0
- package/dist/migration.d.ts +9 -0
- package/dist/paths.d.ts +4 -1
- package/dist/registry.d.ts +1 -0
- package/dist/runs.d.ts +2 -0
- package/dist/tools.d.ts +1 -1
- package/package.json +1 -1
- package/skill/opencode-jobs/SKILL.md +10 -3
package/dist/internals.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deriveScopeId, shQuote, slugify } from "./paths.js";
|
|
2
2
|
import { cronToOnCalendar, describeCron, parseCron } from "./cron.js";
|
|
3
|
-
import { validateGuard, validateRunSpec, validateSession } from "./job.js";
|
|
3
|
+
import { validateGuard, validateRunSpec, validateSession, validateWorktree } from "./job.js";
|
|
4
4
|
import { buildOpencodeArguments, runScriptContent, serviceContent, timerContent } from "./systemd.js";
|
|
5
5
|
export declare const internals: {
|
|
6
6
|
slugify: typeof slugify;
|
|
@@ -12,6 +12,7 @@ export declare const internals: {
|
|
|
12
12
|
validateRunSpec: typeof validateRunSpec;
|
|
13
13
|
validateGuard: typeof validateGuard;
|
|
14
14
|
validateSession: typeof validateSession;
|
|
15
|
+
validateWorktree: typeof validateWorktree;
|
|
15
16
|
buildOpencodeArguments: typeof buildOpencodeArguments;
|
|
16
17
|
runScriptContent: typeof runScriptContent;
|
|
17
18
|
serviceContent: typeof serviceContent;
|
package/dist/job.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ export interface CommandRun extends RunOptions {
|
|
|
12
12
|
export type RunSpec = PromptRun | CommandRun;
|
|
13
13
|
export declare const SESSION_MODES: readonly ["new", "persist", "compact", "compact+last"];
|
|
14
14
|
export type SessionMode = (typeof SESSION_MODES)[number];
|
|
15
|
+
export interface WorktreeOptions {
|
|
16
|
+
base?: string;
|
|
17
|
+
ref?: string;
|
|
18
|
+
commitMessage?: string;
|
|
19
|
+
}
|
|
15
20
|
export interface Job {
|
|
16
21
|
slug: string;
|
|
17
22
|
name: string;
|
|
@@ -19,6 +24,7 @@ export interface Job {
|
|
|
19
24
|
run: RunSpec;
|
|
20
25
|
session?: SessionMode;
|
|
21
26
|
guard?: string;
|
|
27
|
+
worktree?: WorktreeOptions;
|
|
22
28
|
timeoutSeconds?: number;
|
|
23
29
|
createdAt: string;
|
|
24
30
|
updatedAt: string;
|
|
@@ -34,6 +40,7 @@ export declare function validateRunSpec(run: unknown, context: string): RunSpec;
|
|
|
34
40
|
export declare function validateSession(value: unknown, context: string): SessionMode;
|
|
35
41
|
export declare function validateTimeout(value: unknown, context: string): number | undefined;
|
|
36
42
|
export declare function validateGuard(value: unknown, context: string): string | undefined;
|
|
43
|
+
export declare function validateWorktree(value: unknown, context: string): WorktreeOptions | undefined;
|
|
37
44
|
export declare function loadJobFile(file: string, expectedSlug?: string): JobResult;
|
|
38
45
|
export declare function loadJobs(workdir: string): {
|
|
39
46
|
jobs: Job[];
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export declare function configRoot(): string;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function stateRoot(): string;
|
|
3
|
+
export declare function worktreesDirectory(scopeId: string): string;
|
|
4
|
+
export declare function locksDirectory(scopeId: string): string;
|
|
5
|
+
export declare function jobsStateDirectory(): string;
|
|
3
6
|
export declare function registryPath(): string;
|
|
4
7
|
export declare function scopeDirectory(scopeId: string): string;
|
|
5
8
|
export declare function runsDirectory(scopeId: string): string;
|
package/dist/registry.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface Registry {
|
|
|
9
9
|
version: 1;
|
|
10
10
|
projects: Record<string, RegistryEntry>;
|
|
11
11
|
}
|
|
12
|
+
export declare function readRegistryFile(file: string): Registry;
|
|
12
13
|
export declare function loadRegistry(): Registry;
|
|
13
14
|
export declare function saveRegistry(registry: Registry): void;
|
|
14
15
|
export declare function registryEntry(workdir: string): RegistryEntry | undefined;
|
package/dist/runs.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ declare const runRecordSchema: z.ZodObject<{
|
|
|
10
10
|
exitCode: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
11
11
|
sessionId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
12
12
|
startedBy: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
13
|
+
worktreeBranch: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
14
|
+
worktreeCommit: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
13
15
|
}, z.core.$strip>;
|
|
14
16
|
export type RunRecord = z.infer<typeof runRecordSchema>;
|
|
15
17
|
export declare function readRunRecords(scopeId: string, slug: string, limit: number): RunRecord[];
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type ToolDefinition } from "@opencode-ai/plugin";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const jobsTools: Record<string, ToolDefinition>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-jobs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "opencode plugin that schedules recurring agent jobs as systemd user timers, with git-committable job definitions, run history, and session continuity",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -7,13 +7,13 @@ compatibility: opencode on Linux with systemd
|
|
|
7
7
|
|
|
8
8
|
# OpenCode Jobs
|
|
9
9
|
|
|
10
|
-
Use the `opencode-jobs` tools instead of editing systemd units or global
|
|
11
|
-
|
|
10
|
+
Use the `opencode-jobs` tools instead of editing systemd units or global job
|
|
11
|
+
state directly.
|
|
12
12
|
|
|
13
13
|
## Workflow
|
|
14
14
|
|
|
15
15
|
1. Create or update a definition with `schedule_job`. Definitions belong in
|
|
16
|
-
`.opencode/
|
|
16
|
+
`.opencode/jobs/<slug>.json` and should be committed with the
|
|
17
17
|
project.
|
|
18
18
|
2. Inspect definitions with `list_jobs` or `get_job`.
|
|
19
19
|
3. Run `enable_project` after the first job is created. Run it again to
|
|
@@ -34,6 +34,13 @@ scheduler state directly.
|
|
|
34
34
|
`compact` for summary continuity, or `compact+last` when the previous final
|
|
35
35
|
result must also remain visible.
|
|
36
36
|
- A `guard` is a shell command that must exit zero for the job to run.
|
|
37
|
+
- Set `worktree: true` when the job should not touch the user's checkout:
|
|
38
|
+
each run gets a fresh git worktree (default base
|
|
39
|
+
`~/.local/state/opencode/jobs/worktrees/…`, override with
|
|
40
|
+
`worktree.base`), all changes are committed to a per-run branch
|
|
41
|
+
`opencode-jobs/<slug>/…`, and the worktree is removed. Overlapping runs
|
|
42
|
+
of the same job are skipped via a lock; subdirectory projects run in
|
|
43
|
+
the matching worktree subdirectory. Requires a git repository.
|
|
37
44
|
- Scheduled jobs require Linux, a systemd user session, and an `opencode`
|
|
38
45
|
executable available to the timer environment.
|
|
39
46
|
|