superagent-skill 0.1.0 → 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/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as reached, C as USER_ERRORS, D as latestAssignment, E as isoTime, F as ticketOutcome, I as waitsForPerson, M as runningAssignment, N as settled, O as latestReport, P as threadKey, S as key, T as followupOwners, _ as REASONS, a as readSettings, b as canRetry, c as AGENT_NAMES, d as REPORT_FILE, f as readReport, g as Engine, h as readState, i as parseYaml, j as readUntil, k as liveTicket, l as installed, m as FileRepositories, n as SettingsSchema, o as stringifyYaml, p as reportInstructions, r as defaultSettings, s as writeSettings, t as SETTINGS_FILE, u as runnerFor, v as reasonText, w as UserError, x as ticketStage, y as said } from "./settings-BewLFAqT.mjs";
1
+ import { A as ticketStage, B as readUntil, D as reasonText, E as REASONS, F as isoTime, G as waitsForPerson, H as settled, I as latestAssignment, L as latestReport, M as USER_ERRORS, N as UserError, O as said, P as followupOwners, R as liveTicket, T as Engine, U as threadKey, V as runningAssignment, W as ticketOutcome, _ as AdmissionDirectionSchema, a as readSettings, b as directionAllowed, c as AGENT_NAMES, d as REPORT_FILE, f as readReport, g as readState, h as FileRepositories, i as parseYaml, j as key, k as canRetry, l as installed, n as SettingsSchema, o as stringifyYaml, p as reportInstructions, r as defaultSettings, s as writeSettings, t as SETTINGS_FILE, u as runnerFor, v as RuleAssessmentSchema, y as RuleMatchSchema, z as reached } from "./settings-D8KZBXO7.mjs";
2
2
  // src/core/memory.ts
3
3
  /** In-memory repository implementation for testing and ephemeral engine instances. */
4
4
  const clone = (value) => structuredClone(value);
@@ -67,4 +67,4 @@ var MemoryRepositories = class {
67
67
  byThread: (key) => [...this.decisionRows.values()].filter((decision) => decision.threadKey === key).map(clone)
68
68
  };
69
69
  };
70
- export { AGENT_NAMES, Engine, FileRepositories, MemoryRepositories, REASONS, REPORT_FILE, SETTINGS_FILE, SettingsSchema, USER_ERRORS, UserError, canRetry, defaultSettings, followupOwners, installed, isoTime, key, latestAssignment, latestReport, liveTicket, parseYaml, reached, readReport, readSettings, readState, readUntil, reasonText, reportInstructions, runnerFor, runningAssignment, said, settled, stringifyYaml, threadKey, ticketOutcome, ticketStage, waitsForPerson, writeSettings };
70
+ export { AGENT_NAMES, AdmissionDirectionSchema, Engine, FileRepositories, MemoryRepositories, REASONS, REPORT_FILE, RuleAssessmentSchema, RuleMatchSchema, SETTINGS_FILE, SettingsSchema, USER_ERRORS, UserError, canRetry, defaultSettings, directionAllowed, followupOwners, installed, isoTime, key, latestAssignment, latestReport, liveTicket, parseYaml, reached, readReport, readSettings, readState, readUntil, reasonText, reportInstructions, runnerFor, runningAssignment, said, settled, stringifyYaml, threadKey, ticketOutcome, ticketStage, waitsForPerson, writeSettings };
@@ -1,8 +1,8 @@
1
1
  import { createHash } from "node:crypto";
2
- import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
3
- import { basename, join } from "node:path";
4
- import { spawn } from "node:child_process";
5
2
  import { z } from "zod";
3
+ import { lstat, mkdir, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
4
+ import { basename, delimiter, join } from "node:path";
5
+ import { spawn } from "node:child_process";
6
6
  // src/core/model.ts
7
7
  /** Stable key of a thread across the whole domain. */
8
8
  const threadKey = (ref) => `${ref.source}:${ref.id}`;
@@ -655,20 +655,21 @@ var Tickets = class extends EnginePart {
655
655
  }
656
656
  /** Replace a ticket's running Assignment with a new one that receives `note` first, and queue it for launch. */
657
657
  restart(ticket, running, reason, note) {
658
- this.endAssignment(ticket, running, reason);
659
- this.requeueUntaken(ticket, running);
660
- const assignment = this.newAssignment(ticket);
661
658
  const at = this.now();
662
659
  const input = {
663
- id: key("input", ticket.id, "restart", assignment.id),
660
+ id: key("input", ticket.id, "restart", running.id, at),
664
661
  kind: "text",
665
662
  text: note,
666
663
  at
667
664
  };
668
665
  ticket.inputs.push(input);
666
+ this.endAssignment(ticket, running, reason);
667
+ this.requeueUntaken(ticket, running);
668
+ const assignment = this.newAssignment(ticket);
669
669
  ticket.undelivered.push(input.id);
670
670
  ticket.updatedAt = at;
671
671
  this.repo.tickets.save(ticket);
672
+ this.options.executor.stop(ticket, running, reason);
672
673
  this.options.executor.start(ticket, assignment);
673
674
  }
674
675
  /**
@@ -1079,7 +1080,7 @@ var Evals = class extends EnginePart {
1079
1080
  const reasons = [];
1080
1081
  let strongest;
1081
1082
  for (const trigger of triggers) {
1082
- const gate = policy.gate(trigger, thread, tickets);
1083
+ const gate = policy.gate(trigger, thread, tickets, this.options.scope.scope(trigger));
1083
1084
  if (!gate.admissible) {
1084
1085
  reasons.push({
1085
1086
  code: gate.reason,
@@ -1331,7 +1332,7 @@ var Evals = class extends EnginePart {
1331
1332
  */
1332
1333
  directEval(thread, trigger, kind, ticketId) {
1333
1334
  const policy = this.policy();
1334
- const gate = policy.gate(trigger, thread, this.ticketsOnThread(thread));
1335
+ const gate = policy.gate(trigger, thread, this.ticketsOnThread(thread), this.options.scope.scope(trigger));
1335
1336
  if (!gate.admissible) throw new UserError("notAdmissible", { reason: gate.reason });
1336
1337
  const at = this.now();
1337
1338
  if (thread.pending.includes(trigger.id)) {
@@ -1925,6 +1926,235 @@ var Engine = class {
1925
1926
  });
1926
1927
  }
1927
1928
  };
1929
+ // src/core/limits.ts
1930
+ /** Validation bounds shared between host schemas and management panel forms. */
1931
+ const LIMITS = {
1932
+ ruleName: 100,
1933
+ ruleInstruction: 2e3,
1934
+ evalTimeoutSeconds: {
1935
+ min: 30,
1936
+ max: 600
1937
+ },
1938
+ maxWorkers: {
1939
+ min: 1,
1940
+ max: 16
1941
+ },
1942
+ prepareCommand: 4e3,
1943
+ promptMaxChars: {
1944
+ min: 1e3,
1945
+ max: 1e6
1946
+ },
1947
+ admissionContextMaxPages: {
1948
+ min: 1,
1949
+ max: 100
1950
+ },
1951
+ admissionContextTimeoutMs: {
1952
+ min: 1,
1953
+ max: 9e4
1954
+ }
1955
+ };
1956
+ new Intl.Segmenter("zh", { granularity: "word" });
1957
+ /** Case-insensitive comparison for GitHub logins and repository names. */
1958
+ const sameName = (a, b) => a.toLowerCase() === b.toLowerCase();
1959
+ const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1960
+ // src/infra/environment.ts
1961
+ /**
1962
+ * Writes the CLI shims and the isolated git configuration that bind a run to the agent's accounts.
1963
+ *
1964
+ * Each shim strips its own directory from PATH before it execs, so a wrapper script that resolves `gh` by name reaches the
1965
+ * real binary instead of looping. The git configuration replaces the operator's global configuration for the run, so a
1966
+ * worker cannot push with the operator's credentials.
1967
+ *
1968
+ * These are guardrails, not an OS boundary: a run shares the operator's OS user and can read their home directory.
1969
+ */
1970
+ const MARKER = "# Written by superagent on every start; edits are lost.";
1971
+ /** Commands the shims provide, which a blocked list must never shadow. */
1972
+ const WORKER_COMMANDS = [
1973
+ "gh",
1974
+ "git",
1975
+ "lark-cli"
1976
+ ];
1977
+ const workerBin = (stateDir) => join(stateDir, "worker-bin");
1978
+ const workerGitConfig = (stateDir) => join(stateDir, "worker-gitconfig");
1979
+ const shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
1980
+ const gitQuote = (value) => `"${value.replace(/[\\"]/g, (char) => `\\${char}`)}"`;
1981
+ const credentialHelper = (cli) => `!${shellQuote(cli)} auth git-credential`;
1982
+ async function written(file) {
1983
+ try {
1984
+ const stat = await lstat(file);
1985
+ if (!stat.isFile() || stat.size > 4096) return false;
1986
+ return (await readFile(file, "utf8")).includes(MARKER);
1987
+ } catch {
1988
+ return false;
1989
+ }
1990
+ }
1991
+ async function own(file, content) {
1992
+ const temporary = `${file}.${process.pid}.tmp`;
1993
+ await writeFile(temporary, content, { mode: 384 });
1994
+ await rename(temporary, file);
1995
+ }
1996
+ /**
1997
+ * Writes the shims and git configuration, refusing to overwrite files it did not write.
1998
+ * @throws when a file in the shim directory or at the git configuration path was written by something else.
1999
+ */
2000
+ async function writeEnvironment(accounts, blockedCommands) {
2001
+ const dir = workerBin(accounts.stateDir);
2002
+ await mkdir(dir, { recursive: true });
2003
+ const before = await readdir(dir);
2004
+ for (const name of before) if (!await written(join(dir, name))) throw new Error(`The file ${join(dir, name)} was not written by superagent; move it away or choose another state directory.`);
2005
+ const kept = /* @__PURE__ */ new Set();
2006
+ const shim = async (name, body) => {
2007
+ const temporary = join(dir, `.${name}.${process.pid}.tmp`);
2008
+ await writeFile(temporary, `#!/bin/sh\n${MARKER}\n${body}\n`, { mode: 493 });
2009
+ await rename(temporary, join(dir, name));
2010
+ kept.add(name);
2011
+ };
2012
+ const withoutShims = [
2013
+ `self=${shellQuote(dir)}`,
2014
+ "rest=",
2015
+ "IFS=:",
2016
+ "set -f",
2017
+ "for entry in $PATH; do [ \"$entry\" = \"$self\" ] || rest=\"${rest:+$rest:}$entry\"; done",
2018
+ "set +f",
2019
+ "unset IFS",
2020
+ "PATH=$rest",
2021
+ "export PATH"
2022
+ ].join("\n");
2023
+ const run = (program) => `${withoutShims}\nexec ${shellQuote(program)} "$@"`;
2024
+ const fail = (message) => `echo ${shellQuote(message)} >&2\nexit 1`;
2025
+ await shim("gh", run(accounts.githubCli));
2026
+ await shim("lark-cli", accounts.feishuCli ? run(accounts.feishuCli) : fail("lark-cli is unavailable: this installation has no Feishu bot."));
2027
+ for (const name of new Set(blockedCommands.filter((name) => !WORKER_COMMANDS.includes(name)))) await shim(name, fail(`${name} is blocked in this installation; use gh, which acts as ${accounts.agentLogin}.`));
2028
+ for (const name of before) if (!kept.has(name)) await unlink(join(dir, name));
2029
+ await own(workerGitConfig(accounts.stateDir), [
2030
+ MARKER,
2031
+ "[user]",
2032
+ " useConfigOnly = true",
2033
+ "[credential]",
2034
+ " helper =",
2035
+ "[credential \"https://github.com\"]",
2036
+ `\thelper = ${gitQuote(credentialHelper(accounts.githubCli))}`,
2037
+ "[url \"https://github.com/\"]",
2038
+ " insteadOf = git@github.com:",
2039
+ " insteadOf = ssh://git@github.com:",
2040
+ "[filter \"lfs\"]",
2041
+ " clean = git-lfs clean -- %f",
2042
+ " smudge = git-lfs smudge -- %f",
2043
+ " process = git-lfs filter-process",
2044
+ " required = true"
2045
+ ].join("\n") + "\n");
2046
+ }
2047
+ /** Environment variables a run receives, with the shim directory first on PATH. */
2048
+ function runEnvironment(accounts, variables) {
2049
+ return {
2050
+ ...variables,
2051
+ PATH: [workerBin(accounts.stateDir), process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin"].join(delimiter),
2052
+ GIT_CONFIG_GLOBAL: workerGitConfig(accounts.stateDir),
2053
+ GIT_CONFIG_SYSTEM: "/dev/null",
2054
+ GIT_TERMINAL_PROMPT: "0"
2055
+ };
2056
+ }
2057
+ // src/core/policy.ts
2058
+ /**
2059
+ * Runtime settings schemas, assessment validation, and policy gate evaluation.
2060
+ * Who may originate work is configured per Source in that Source's own identities; the Policy never maps a person across Sources.
2061
+ */
2062
+ const RuleIdSchema = z.string().regex(/^[a-zA-Z0-9_-]{1,80}$/);
2063
+ const RuleMatchSchema = z.object({
2064
+ rule_id: RuleIdSchema,
2065
+ reason: z.string().trim().min(1).max(500)
2066
+ }).strict();
2067
+ const RuleAssessmentSchema = RuleMatchSchema.extend({ matched: z.boolean() }).strict();
2068
+ const AdmissionDirectionSchema = z.object({
2069
+ implementation_requested: z.boolean(),
2070
+ target_basis: z.enum([
2071
+ "specified",
2072
+ "existing-standard",
2073
+ "undetermined"
2074
+ ]),
2075
+ requires_design_decision: z.boolean(),
2076
+ evidence: z.string().trim().min(1).max(700)
2077
+ }).strict();
2078
+ /** Check whether an assessment established implementation intent and a settled target without open design decisions. */
2079
+ function directionAllowed(value) {
2080
+ const result = AdmissionDirectionSchema.safeParse(value);
2081
+ return result.success && result.data.implementation_requested && result.data.target_basis !== "undetermined" && !result.data.requires_design_decision;
2082
+ }
2083
+ const DEFAULT_RULES = [{
2084
+ id: "copy",
2085
+ name: "Copy fixes",
2086
+ enabled: true,
2087
+ instruction: "Explicit requests to correct a typo, wording, punctuation or existing translation. Preserve product promises and business meaning."
2088
+ }, {
2089
+ id: "visual",
2090
+ name: "Visual fixes",
2091
+ enabled: true,
2092
+ instruction: "Explicit implementation requests for local spacing, alignment, overflow or styling, with a specified target or an objectively established existing standard/correct state to restore. Locating an element or calling it inconsistent, unattractive or hard to understand does not establish a target. Do not invent visual style, information hierarchy, rendering or interaction decisions. No redesign, new interaction or behavior. A known spacing defect does not authorize adjacent undefined restyling; assess only a clearly separable authorized scope. If direction or scope is unsettled, observe only: no acknowledgement, worker or unsolicited question."
2093
+ }];
2094
+ /** An assessment rule; its instruction may also specify PR reviewers and whether to wait for their approval. */
2095
+ const RuleSchema$1 = z.object({
2096
+ id: RuleIdSchema,
2097
+ name: z.string().trim().min(1).max(LIMITS.ruleName),
2098
+ enabled: z.boolean(),
2099
+ instruction: z.string().trim().min(1).max(LIMITS.ruleInstruction)
2100
+ }).strict();
2101
+ const RoleModelSchema = z.object({
2102
+ provider: z.string().trim().min(1),
2103
+ model: z.string().trim().min(1),
2104
+ reasoningEffort: z.string().trim().min(1).optional()
2105
+ }).strict();
2106
+ const AllowedSchema = z.object({
2107
+ id: z.string().trim().min(1).max(200),
2108
+ name: z.string().trim().max(100).optional()
2109
+ }).strict();
2110
+ const Weak = z.enum(["inferred", "ignore"]);
2111
+ const AdmissionRowSchema = z.object({
2112
+ listedUnaddressed: Weak.optional(),
2113
+ unlistedAddressed: z.enum([
2114
+ "explicit",
2115
+ "inferred",
2116
+ "ignore"
2117
+ ]).optional(),
2118
+ unlistedUnaddressed: Weak.optional()
2119
+ }).strict();
2120
+ const AdmissionTableSchema = z.record(z.string(), AdmissionRowSchema);
2121
+ const SourcePolicySchema = z.object({
2122
+ allowed: z.array(AllowedSchema).default([]),
2123
+ admission: AdmissionTableSchema.default({})
2124
+ }).catchall(z.unknown());
2125
+ const PolicyConfigSchema = z.object({
2126
+ rules: z.array(RuleSchema$1).refine((rules) => new Set(rules.map((rule) => rule.id)).size === rules.length, "Duplicate rule IDs").default(DEFAULT_RULES),
2127
+ sources: z.record(z.string().regex(/^[a-z][a-z0-9-]*$/), SourcePolicySchema).default({})
2128
+ }).strict();
2129
+ const EvalConfigSchema = z.object({
2130
+ mode: z.enum([
2131
+ "off",
2132
+ "observe",
2133
+ "auto"
2134
+ ]).default("observe"),
2135
+ timeoutSeconds: z.number().int().min(LIMITS.evalTimeoutSeconds.min).max(LIMITS.evalTimeoutSeconds.max).default(120),
2136
+ model: RoleModelSchema.nullable().default(null)
2137
+ }).strict();
2138
+ const CommandNameSchema = z.string().regex(/^[A-Za-z0-9._-]+$/).refine((name) => name !== "." && name !== "..", "Not a command name").refine((name) => !WORKER_COMMANDS.includes(name), `${WORKER_COMMANDS.join(", ")} cannot be blocked`);
2139
+ /** Executor settings: worker model, concurrency, ticket directory root (empty defaults to `<stateDir>/work`), `prepare` command, and blocked commands. */
2140
+ const ExecutorConfigSchema = z.object({
2141
+ model: RoleModelSchema.nullable().default(null),
2142
+ maxWorkers: z.number().int().min(LIMITS.maxWorkers.min).max(LIMITS.maxWorkers.max).default(3),
2143
+ directory: z.string().trim().refine((path) => path === "" || path.startsWith("/"), "An absolute path, or empty for <stateDir>/work").default(""),
2144
+ prepare: z.string().max(LIMITS.prepareCommand).default(""),
2145
+ blockedCommands: z.array(CommandNameSchema).default([])
2146
+ }).strict();
2147
+ const SourceInstanceSchema = z.object({
2148
+ enabled: z.boolean().default(true),
2149
+ config: z.record(z.string(), z.unknown()).default({})
2150
+ }).strict();
2151
+ z.object({
2152
+ paused: z.boolean().default(false),
2153
+ sources: z.record(z.string().regex(/^[a-z][a-z0-9-]*$/), SourceInstanceSchema).default({}),
2154
+ policy: PolicyConfigSchema.default(() => PolicyConfigSchema.parse({})),
2155
+ eval: EvalConfigSchema.default(() => EvalConfigSchema.parse({})),
2156
+ executor: ExecutorConfigSchema.default(() => ExecutorConfigSchema.parse({}))
2157
+ }).strict();
1928
2158
  // src/state/files.ts
1929
2159
  /**
1930
2160
  * File-backed durable state.
@@ -2177,6 +2407,8 @@ async function readState(stateDir) {
2177
2407
  return {
2178
2408
  tickets: [],
2179
2409
  threads: [],
2410
+ decisions: [],
2411
+ triggers: [],
2180
2412
  exists: false
2181
2413
  };
2182
2414
  }
@@ -2185,6 +2417,8 @@ async function readState(stateDir) {
2185
2417
  return {
2186
2418
  tickets: repo.tickets.list(),
2187
2419
  threads: repo.threads.list(),
2420
+ decisions: repo.decisions.list(),
2421
+ triggers: repo.triggers.list(),
2188
2422
  exists: true
2189
2423
  };
2190
2424
  }
@@ -2277,7 +2511,8 @@ function reportInstructions() {
2277
2511
  "",
2278
2512
  `Before you stop, write \`${REPORT_FILE}\` in your working directory as one JSON object with these keys:`,
2279
2513
  "",
2280
- "- `summary` (required): one sentence a person can act on.",
2514
+ "- `summary` (required): one short sentence a person can act on, under 200 characters. It is the reply the person sees,",
2515
+ " so leave file names, test counts and other evidence out of it; put that in your pull request or your last message.",
2281
2516
  "- `state`: `ready` when the work is ready for review, `blocked` when a person must supply something, `failed` when it cannot finish.",
2282
2517
  "- `prs`: the pull request URLs you opened, when any.",
2283
2518
  "- `question`: what the person must supply, when `state` is `blocked`.",
@@ -2307,7 +2542,7 @@ var ClaudeRunner = class {
2307
2542
  "--output-format",
2308
2543
  "stream-json",
2309
2544
  "--verbose",
2310
- "--dangerously-skip-permissions",
2545
+ ...run.readOnly ? ["--tools", "Read,Grep,Glob"] : ["--dangerously-skip-permissions"],
2311
2546
  ...run.model ? ["--model", run.model] : []
2312
2547
  ];
2313
2548
  const result = await runProcess(this.binary, argv, {
@@ -2364,7 +2599,7 @@ var CodexRunner = class {
2364
2599
  const argv = [
2365
2600
  "exec",
2366
2601
  "--sandbox",
2367
- "danger-full-access",
2602
+ run.readOnly ? "read-only" : "danger-full-access",
2368
2603
  "--skip-git-repo-check",
2369
2604
  "--json",
2370
2605
  "-o",
@@ -2516,6 +2751,80 @@ const ExecutorSchema = z.object({
2516
2751
  /** Commands a ticket may not run. */
2517
2752
  blockedCommands: z.array(z.string()).default([])
2518
2753
  });
2754
+ const RuleSchema = z.object({
2755
+ /** The id an assessment names; `unasked` is reserved for the verdict that a message asks for work at all. */
2756
+ id: z.string().regex(/^[a-z][a-z0-9_-]{0,79}$/, "lowercase letters, digits, _ and -"),
2757
+ name: z.string().min(1),
2758
+ enabled: z.boolean().default(true),
2759
+ /** What kind of work the rule admits, in the words the assessor reads. */
2760
+ instruction: z.string().min(1)
2761
+ });
2762
+ /** Proactive work: whether an unaddressed message of the owner may become a ticket, and the rules that bound it. */
2763
+ const PolicySchema = z.object({
2764
+ /** `off` never assesses an unaddressed message, `observe` records what it would accept, `auto` accepts it. */
2765
+ mode: z.enum([
2766
+ "off",
2767
+ "observe",
2768
+ "auto"
2769
+ ]).default("observe"),
2770
+ rules: z.array(RuleSchema).default([])
2771
+ });
2772
+ const AttentionSchema = z.object({
2773
+ idleSecondsThreshold: z.number().int().min(10).max(86400).default(300),
2774
+ quietHours: z.object({
2775
+ enabled: z.boolean().default(true),
2776
+ start: z.string().default("23:00"),
2777
+ end: z.string().default("08:00"),
2778
+ morningDigestAt: z.string().default("08:30")
2779
+ }).default({
2780
+ enabled: true,
2781
+ start: "23:00",
2782
+ end: "08:00",
2783
+ morningDigestAt: "08:30"
2784
+ }),
2785
+ minNotifyIntervalMinutes: z.number().int().min(1).max(1440).default(10),
2786
+ maxDailyNotifications: z.number().int().min(1).max(1e3).default(25)
2787
+ });
2788
+ const BudgetSchema = z.object({
2789
+ autonomousCooldownSeconds: z.number().int().min(0).max(86400).default(180),
2790
+ maxAutonomousWakesPerDay: z.number().int().min(1).max(1e3).default(48)
2791
+ });
2792
+ const TimerScheduleSchema = z.object({
2793
+ id: z.string().min(1),
2794
+ cron: z.string().optional(),
2795
+ intervalMinutes: z.number().int().min(1).optional(),
2796
+ prompt: z.string().min(1)
2797
+ });
2798
+ const TimersSchema = z.object({
2799
+ enabled: z.boolean().default(true),
2800
+ schedules: z.array(TimerScheduleSchema).default([])
2801
+ });
2802
+ const WatcherSchema = z.object({
2803
+ id: z.string().min(1),
2804
+ intervalMinutes: z.number().int().min(1).default(10),
2805
+ command: z.string().min(1),
2806
+ instruction: z.string().min(1)
2807
+ });
2808
+ const PrReviewSchema = z.object({
2809
+ /** Whether autonomous PR review is enabled. */
2810
+ enabled: z.boolean().default(true),
2811
+ /** When true, actively polls open PRs in the repository. */
2812
+ pollOpenPrs: z.boolean().default(true),
2813
+ /** Commands to run locally inside the worktree to verify the PR, e.g. ["npm test", "npm run build"]. */
2814
+ verifyCommands: z.array(z.string()).default([]),
2815
+ /** Timeout in seconds for each verify command. Default 300s. */
2816
+ verifyTimeoutSeconds: z.number().int().min(10).max(3600).default(300),
2817
+ /** Whether to automatically merge the PR if tests pass and review passes. */
2818
+ autoMerge: z.boolean().default(false),
2819
+ /** Method to use when auto-merging: "squash" | "merge" | "rebase". Default "squash". */
2820
+ mergeMethod: z.enum([
2821
+ "squash",
2822
+ "merge",
2823
+ "rebase"
2824
+ ]).default("squash"),
2825
+ /** Whether community PRs (from authors not explicitly in allowed list) may be reviewed. */
2826
+ allowCommunityPrs: z.boolean().default(true)
2827
+ });
2519
2828
  const SettingsSchema = z.object({
2520
2829
  /** Where tickets, triggers and logs live, as an absolute path. */
2521
2830
  stateDir: z.string().min(1),
@@ -2529,7 +2838,9 @@ const SettingsSchema = z.object({
2529
2838
  /** How often to poll notifications, in seconds. */
2530
2839
  pollSeconds: z.number().int().min(15).max(3600).default(60),
2531
2840
  /** GitHub logins that may ask for work. Empty accepts nobody. */
2532
- allowed: z.array(z.string()).default([])
2841
+ allowed: z.array(z.string()).default([]),
2842
+ /** Pull request review, checkout, and verification settings. */
2843
+ prReview: PrReviewSchema.optional()
2533
2844
  }).optional(),
2534
2845
  feishu: z.object({
2535
2846
  enabled: z.boolean().default(true),
@@ -2546,11 +2857,40 @@ const SettingsSchema = z.object({
2546
2857
  allowed: z.array(z.string()).default([]),
2547
2858
  syncChat: z.string().optional()
2548
2859
  }).optional(),
2860
+ twitter: z.object({
2861
+ enabled: z.boolean().default(true),
2862
+ /** The CLI that acts as Twitter client (opencli). */
2863
+ cli: z.string().default("opencli"),
2864
+ /** Search query or keywords to monitor (e.g. "superagent OR @smallnest"). */
2865
+ query: z.string().min(1),
2866
+ /** How often to poll Twitter search, in seconds. */
2867
+ pollSeconds: z.number().int().min(15).max(3600).default(300),
2868
+ /** Twitter handles that may trigger tickets; empty accepts any user matching the query. */
2869
+ allowed: z.array(z.string()).default([])
2870
+ }).optional(),
2549
2871
  executor: ExecutorSchema.optional().transform((value) => ExecutorSchema.parse(value ?? {})),
2872
+ policy: PolicySchema.optional().transform((value) => PolicySchema.parse(value ?? {})),
2873
+ /** Who assesses a candidate and with what: the `claude` CLI, or a runner named here. */
2874
+ assess: z.object({
2875
+ agent: z.enum(AGENT_NAMES).default("claude"),
2876
+ binary: z.string().optional(),
2877
+ model: z.string().optional()
2878
+ }).optional().transform((value) => ({
2879
+ agent: "claude",
2880
+ ...value
2881
+ })),
2550
2882
  /** Branch names the agent pushes, as a prefix followed by the ticket's short name. */
2551
2883
  branchPrefix: z.string().default("agent/"),
2552
2884
  /** The operator's own instructions, appended to every ticket's prompt in their words. */
2553
- prompts: z.string().default("")
2885
+ prompts: z.string().default(""),
2886
+ /** Human presence and attention routing configuration. */
2887
+ attention: AttentionSchema.optional().transform((value) => AttentionSchema.parse(value ?? {})),
2888
+ /** Token and autonomous wakeup protection guard. */
2889
+ budget: BudgetSchema.optional().transform((value) => BudgetSchema.parse(value ?? {})),
2890
+ /** Autonomous timers and schedules. */
2891
+ timers: TimersSchema.optional().transform((value) => TimersSchema.parse(value ?? {})),
2892
+ /** Pull-based active watchers for external sources without webhooks. */
2893
+ watchers: z.array(WatcherSchema).default([])
2554
2894
  });
2555
2895
  /** The default an installation starts from, for `superagent init`. */
2556
2896
  function defaultSettings(cwd, home) {
@@ -2702,4 +3042,4 @@ function stringifyYaml(value, indent = 0) {
2702
3042
  }).join("\n");
2703
3043
  }
2704
3044
  const needsQuote = (text) => text === "" || /^[\s"'-]|[:#]|\s$|^(true|false|null|~|-?\d+(\.\d+)?)$/.test(text);
2705
- export { reached as A, USER_ERRORS as C, latestAssignment as D, isoTime as E, ticketOutcome as F, waitsForPerson as I, runningAssignment as M, settled as N, latestReport as O, threadKey as P, key as S, followupOwners as T, REASONS as _, readSettings as a, canRetry as b, AGENT_NAMES as c, REPORT_FILE as d, readReport as f, Engine as g, readState as h, parseYaml as i, readUntil as j, liveTicket as k, installed as l, FileRepositories as m, SettingsSchema as n, stringifyYaml as o, reportInstructions as p, defaultSettings as r, writeSettings as s, SETTINGS_FILE as t, runnerFor as u, reasonText as v, UserError as w, ticketStage as x, said as y };
3045
+ export { ticketStage as A, readUntil as B, escapeRegExp as C, reasonText as D, REASONS as E, isoTime as F, waitsForPerson as G, settled as H, latestAssignment as I, latestReport as L, USER_ERRORS as M, UserError as N, said as O, followupOwners as P, liveTicket as R, writeEnvironment as S, Engine as T, threadKey as U, runningAssignment as V, ticketOutcome as W, AdmissionDirectionSchema as _, readSettings as a, directionAllowed as b, AGENT_NAMES as c, REPORT_FILE as d, readReport as f, readState as g, FileRepositories as h, parseYaml as i, key as j, canRetry as k, installed as l, runProcess as m, SettingsSchema as n, stringifyYaml as o, reportInstructions as p, defaultSettings as r, writeSettings as s, SETTINGS_FILE as t, runnerFor as u, RuleAssessmentSchema as v, sameName as w, runEnvironment as x, RuleMatchSchema as y, reached as z };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "superagent-skill",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
- "description": "A headless, file-backed agent that turns requests from GitHub issues or Feishu chats into tickets and runs each ticket on a configurable coding agent: Claude Code, Codex or opencode.",
5
+ "description": "A headless, file-backed agent that turns requests from GitHub issues, Feishu chats, or Twitter mentions into tickets and runs each ticket on a configurable coding agent: Claude Code, Codex or opencode.",
6
6
  "bin": {
7
- "superagent": "./bin/superagent.js"
7
+ "superagent": "bin/superagent.js"
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsdown",
@@ -33,6 +33,8 @@
33
33
  "opencode",
34
34
  "feishu",
35
35
  "github",
36
+ "twitter",
37
+ "always-on",
36
38
  "automation",
37
39
  "tickets"
38
40
  ],
@@ -41,7 +43,8 @@
41
43
  "lib",
42
44
  "README.md",
43
45
  "SKILL.md",
44
- "LICENSE"
46
+ "LICENSE",
47
+ "prompts"
45
48
  ],
46
49
  "repository": {
47
50
  "type": "git",
@@ -0,0 +1,4 @@
1
+ Describe the change in the pull request, with the checks you ran and any limitation a reviewer should know.
2
+
3
+ If a person's branch or pull request already contains this change, close your pull request with one sentence naming theirs.
4
+ Do not close it for work that is only related.
@@ -0,0 +1,5 @@
1
+ Review the pull request carefully before approving or merging.
2
+ Presume community PRs may be authored by unassisted coding agents without human testing.
3
+ Verify that all unit tests, linters, and builds have succeeded locally in the checked-out worktree.
4
+ Never merge code that breaks existing tests, introduces security flaws, or degrades maintainability.
5
+ If changes are needed, provide constructive, line-specific feedback or close unfixable/spam PRs.
@@ -0,0 +1,5 @@
1
+ Keep the change to what the request asks for. A message that names one element does not authorize restyling its neighbours
2
+ or settling an open design question.
3
+
4
+ Ask one concrete question when the request leaves a material decision open. Do not ask about routine steps you can decide
5
+ yourself, and do not ask for permission for work the request already authorizes.