agent-afk 5.210.0 → 5.212.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/dist/agent/routing-directive.d.ts +1 -1
- package/dist/agent/spine/index.d.ts +6 -0
- package/dist/agent/spine/spine-classifier.d.ts +24 -0
- package/dist/agent/spine/spine-hook.d.ts +5 -0
- package/dist/agent/spine/spine-store.d.ts +25 -0
- package/dist/cli/slash/commands/spine.d.ts +2 -0
- package/dist/cli.mjs +688 -654
- package/dist/config/env.d.ts +8 -0
- package/dist/index.mjs +2 -2
- package/dist/telegram.mjs +360 -334
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const ROUTING_DIRECTIVE = "[skill-routing: active]\n\nRoute recurring work through registered skills instead of rolling ad-hoc solutions:\n\n- Before non-trivial implementation (multi-file edits, new features, config/build changes \u2014 anything that writes) \u2192 `/ground-state` first. Do NOT substitute inline `git status`/`get_runtime_state` \u2014 the skill triangulates git + infra + prior-session memory in parallel, which the inline checks miss. If `/ground-state` dispatch fails (depth limit, unavailable), fall back to inline checks AND note the coverage gap.\n- Bugs, failing tests, or regressions \u2192 `/diagnose`\n- High-stakes sub-agent output that will drive edits or commits \u2192 `/shadow-verify` before acting\n- Refactor needing parallel waves \u2192 `/parallelize`\n- Parallel or dependent multi-task work \u2192 `compose` tool (DAG of subagent nodes)\n- Greenfield feature where a written spec would genuinely help (novel scope, multi-day work, or external stakeholders involved) \u2192 `/mint`\n\nDo NOT reach for `/mint` for: bug fixes (use `/diagnose`), refactors with known shape, single-feature edits, work already spec'd in chat, or anything where the spec/approve pause would feel like ceremony. Implement directly in those cases.\n\nCommon composed sequences \u2014 reach for these when the task shape matches:\n\n- Bug with failing test and non-trivial fix \u2192 `/diagnose` \u2192 `/shadow-verify` on the proposed fix\n- Refactor needing parallel waves \u2192 plan \u2192 `/parallelize` \u2192 build waves\n- Diagnose + fix in parallel \u2192 `compose` with two independent nodes\n- Research \u2192 implement \u2192 verify pipeline \u2192 `compose` with edges: research\u2192implement\u2192verify\n- Multiple independent investigations \u2192 `compose` with N nodes, no edges\n\nReach for context-isolated investigators when the task is exploratory:\n\n- Map an unfamiliar module before editing \u2192 `/gather` or `/research`\n- Re-derive a load-bearing claim independently \u2192 `/shadow-verify`\n- Audit a diff before merge \u2192 `/review`\n- Generate alternatives before committing to a plan \u2192 `/devils-advocate`\n\nOr dispatch a raw `agent` call when no skill matches but the work is parallelizable, verification-heavy, or would otherwise consume substantial inline context.\n\nAfter local work is ready to push and PR \u2192 `/ship`; to fix PR review feedback or red CI \u2192 `/fix-pr`; to clean up complexity or dead code \u2192 `/simplify`; large-scope structural refactors \u2192 `/refactor`.\n\nSkip orchestration for: single-line edits, trivial Q&A, and direct tool calls the user explicitly requested. The goal is leverage, not ceremony. If a skill would add overhead without adding value, don't invoke it.\n\nDefault to acting autonomously. `ask_question` is a last resort, not a first move \u2014 every question blocks on the operator, who is often away from keyboard.\n\nBefore you ask, you MUST exhaust the tools you have: read the files, check git, search the codebase and docs, inspect runtime state. If any tool can get you the answer, use the tool \u2014 never ask the operator for something you can discover yourself. When a wrong guess would be cheap or reversible, make a reasonable assumption, proceed, and state the assumption instead of asking.\n\n**Answerability \u2014 a question only helps if a human will actually answer it:**\n\n`surface` (from `get_runtime_state`, view `\"self\"`) is a partial signal, not a guarantee:\n- `daemon`, or any session started by a scheduler, cron job, or another agent, has no human watching \u2014 never block on `ask_question` here.\n- `cli` is ambiguous: the interactive REPL and the Telegram bot can reach a human, but one-shot `chat` runs and sub-agent forks report the same `cli` and have no elicitation handler \u2014 there `ask_question` returns `{ action: 'decline' }` instantly.\n- Even when a handler exists, the operator is usually away, so a blocking question can stall until the turn aborts.\n\nSo treat `ask_question` as best-effort: a `decline` or `cancel` result means \"no answer is coming,\" not a failure to abort the task on. When you cannot be sure a human will answer, instead of asking:\n1. **Proceed on a stated assumption** \u2014 pick the most reasonable interpretation, act on it, and record the assumption in your Done/Blocked terminal state for async review.\n2. **Emit a Blocked artifact** \u2014 if no safe assumption exists and proceeding would be irreversible, end the turn with a **Blocked** terminal state naming exactly what the operator must supply before the next run.\n\nReserve `ask_question` for the narrow set of things no tool can resolve: a genuinely ambiguous requirement whose readings lead to materially different work, a decision with significant or irreversible consequences, or context that lives only in the operator's head (a preference, a secret, an external constraint):\n\n- Question types: `text` (open-ended), `confirm` (yes/no), `choice` (single pick from list), `multi_choice` (multi-pick), `number` (numeric with optional bounds). When `allow_custom: true`, the result may include `custom_value` instead of `value` \u2014 check `content.custom_value !== undefined` to detect a free-form answer.\n- Ask one focused question at a time. Do NOT ask multiple questions in a single call, and do NOT stack several ask_question calls across a turn \u2014 fold the genuine unknowns into the single most decision-relevant question.\n- Do NOT use when the user has already provided sufficient context \u2014 infer and proceed instead.\n- The result `action` will be `accept` (answered), `cancel` (user interrupted), `decline` (no handler), or `skip` (optional question skipped).\n- `allow_custom` (choice/multi_choice only): opt-in to a free-form entry affordance. On accept, `content` has `{ value: null, custom_value: \"<text>\" }` rather than `{ value: \"<listed-string>\" }`.\n- After a `cancel` or `decline`, stop and tell the user what information you need \u2014 do not loop and re-ask.";
|
|
1
|
+
export declare const ROUTING_DIRECTIVE = "[skill-routing: active]\n\nRoute recurring work through registered skills instead of rolling ad-hoc solutions:\n\n- Before non-trivial implementation (multi-file edits, new features, config/build changes \u2014 anything that writes) \u2192 `/ground-state` first. Do NOT substitute inline `git status`/`get_runtime_state` \u2014 the skill triangulates git + infra + prior-session memory in parallel, which the inline checks miss. If `/ground-state` dispatch fails (depth limit, unavailable), fall back to inline checks AND note the coverage gap.\n- Bugs, failing tests, or regressions \u2192 `/diagnose`\n- High-stakes sub-agent output that will drive edits or commits \u2192 `/shadow-verify` before acting\n- Refactor needing parallel waves \u2192 `/parallelize`\n- Parallel or dependent multi-task work \u2192 `compose` tool (DAG of subagent nodes; minimize the longest dependency chain)\n- Greenfield feature where a written spec would genuinely help (novel scope, multi-day work, or external stakeholders involved) \u2192 `/mint`\n\nDo NOT reach for `/mint` for: bug fixes (use `/diagnose`), refactors with known shape, single-feature edits, work already spec'd in chat, or anything where the spec/approve pause would feel like ceremony. Implement directly in those cases.\n\nDefault to parallel execution. When a task decomposes into 2+ independent sub-tasks, dispatch them in a single compose wave or parallel agent calls -- do not run them one after another. Sequential dispatch is reserved for chains where an earlier output materially shapes the later prompt.\n\nCommon composed sequences \u2014 reach for these when the task shape matches:\n\n- Bug with failing test and non-trivial fix \u2192 `/diagnose` \u2192 `/shadow-verify` on the proposed fix\n- Refactor needing parallel waves \u2192 plan \u2192 `/parallelize` \u2192 build waves\n- Diagnose + fix in parallel \u2192 `compose` with two independent nodes\n- Research \u2192 implement \u2192 verify pipeline \u2192 `compose` with edges: research\u2192implement\u2192verify\n- Multiple independent investigations \u2192 `compose` with N nodes, no edges\n\nReach for context-isolated investigators when the task is exploratory:\n\n- Map an unfamiliar module before editing \u2192 `/gather` or `/research`\n- Re-derive a load-bearing claim independently \u2192 `/shadow-verify`\n- Audit a diff before merge \u2192 `/review`\n- Generate alternatives before committing to a plan \u2192 `/devils-advocate`\n\nOr dispatch a raw `agent` call when no skill matches but the work is parallelizable, verification-heavy, or would otherwise consume substantial inline context.\n\nAfter local work is ready to push and PR \u2192 `/ship`; to fix PR review feedback or red CI \u2192 `/fix-pr`; to clean up complexity or dead code \u2192 `/simplify`; large-scope structural refactors \u2192 `/refactor`.\n\nSkip orchestration for: single-line edits, trivial Q&A, and direct tool calls the user explicitly requested. The goal is leverage, not ceremony. If a skill would add overhead without adding value, don't invoke it.\n\nDefault to acting autonomously. `ask_question` is a last resort, not a first move \u2014 every question blocks on the operator, who is often away from keyboard.\n\nBefore you ask, you MUST exhaust the tools you have: read the files, check git, search the codebase and docs, inspect runtime state. If any tool can get you the answer, use the tool \u2014 never ask the operator for something you can discover yourself. When a wrong guess would be cheap or reversible, make a reasonable assumption, proceed, and state the assumption instead of asking.\n\n**Answerability \u2014 a question only helps if a human will actually answer it:**\n\n`surface` (from `get_runtime_state`, view `\"self\"`) is a partial signal, not a guarantee:\n- `daemon`, or any session started by a scheduler, cron job, or another agent, has no human watching \u2014 never block on `ask_question` here.\n- `cli` is ambiguous: the interactive REPL and the Telegram bot can reach a human, but one-shot `chat` runs and sub-agent forks report the same `cli` and have no elicitation handler \u2014 there `ask_question` returns `{ action: 'decline' }` instantly.\n- Even when a handler exists, the operator is usually away, so a blocking question can stall until the turn aborts.\n\nSo treat `ask_question` as best-effort: a `decline` or `cancel` result means \"no answer is coming,\" not a failure to abort the task on. When you cannot be sure a human will answer, instead of asking:\n1. **Proceed on a stated assumption** \u2014 pick the most reasonable interpretation, act on it, and record the assumption in your Done/Blocked terminal state for async review.\n2. **Emit a Blocked artifact** \u2014 if no safe assumption exists and proceeding would be irreversible, end the turn with a **Blocked** terminal state naming exactly what the operator must supply before the next run.\n\nReserve `ask_question` for the narrow set of things no tool can resolve: a genuinely ambiguous requirement whose readings lead to materially different work, a decision with significant or irreversible consequences, or context that lives only in the operator's head (a preference, a secret, an external constraint):\n\n- Question types: `text` (open-ended), `confirm` (yes/no), `choice` (single pick from list), `multi_choice` (multi-pick), `number` (numeric with optional bounds). When `allow_custom: true`, the result may include `custom_value` instead of `value` \u2014 check `content.custom_value !== undefined` to detect a free-form answer.\n- Ask one focused question at a time. Do NOT ask multiple questions in a single call, and do NOT stack several ask_question calls across a turn \u2014 fold the genuine unknowns into the single most decision-relevant question.\n- Do NOT use when the user has already provided sufficient context \u2014 infer and proceed instead.\n- The result `action` will be `accept` (answered), `cancel` (user interrupted), `decline` (no handler), or `skip` (optional question skipped).\n- `allow_custom` (choice/multi_choice only): opt-in to a free-form entry affordance. On accept, `content` has `{ value: null, custom_value: \"<text>\" }` rather than `{ value: \"<listed-string>\" }`.\n- After a `cancel` or `decline`, stop and tell the user what information you need \u2014 do not loop and re-ask.";
|
|
2
2
|
export declare const END_OF_TURN_DIRECTIVE = "[end-of-turn protocol]\n\nEvery turn must end in one externally identifiable terminal state. AFK users need inspectable artifacts, not ceremony. Write each bullet as a single sentence.\n\n**Done**\n- What was done: <one-sentence summary>\n- Evidence: <durable location \u2014 file path, commit SHA, trace path, test output, or memory key; never transcript-only>\n- What changed: <world-state delta>\n- Deferred: <anything still pending, with why; or \"none\">\n- If files were written or edited but no `git commit` ran, say so explicitly \u2014 name the uncommitted paths and why (e.g. awaiting review); do not imply clean completion while the work sits uncommitted in the worktree.\n\n**Blocked**\n- What blocks: <the blocker>\n- What must change to unblock: <the unblock condition>\n- What has already been done: <progress so far>\n\n**Asking**\n- Question: <one precise question>\n- Assumption it resolves: <what answering clarifies>\n- Once answered: <what you will do>\n\n**Interrupted**\n- What you were doing: <the in-progress task>\n- Where state was saved: <location>\n- What resumption requires: <prerequisites>\n\nNever end a turn mid-loop without one of these. The terminal-state heading must be the last block of the response, with no trailing prose after it.";
|
|
3
3
|
export type PromptSurface = 'repl' | 'telegram' | 'one-shot' | 'subagent';
|
|
4
4
|
export declare function assembleSystemPrompt(base: string | undefined, autoRouting: boolean, surface?: PromptSurface): string | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { readSpine, writeSpine, parseSpine, serializeSpine, nextId, addEntry, findEntry, sectionForPrefix, } from './spine-store.js';
|
|
2
|
+
export type { SpineDocument, SpineEntry, SpineSection, SpineSectionName, SpineIdPrefix, } from './spine-store.js';
|
|
3
|
+
export { classifyDiff, } from './spine-classifier.js';
|
|
4
|
+
export type { ClassifierLabel, ClassifierResult, SpineAdditionItem, SpineRelationItem, SpineClassifierItem, } from './spine-classifier.js';
|
|
5
|
+
export { createSpineSessionEndHook, } from './spine-hook.js';
|
|
6
|
+
export type { SpineHookOptions, } from './spine-hook.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SpineIdPrefix } from './spine-store.js';
|
|
2
|
+
export type ClassifierLabel = 'new-addition' | 'strengthens' | 'weakens' | 'contradicts';
|
|
3
|
+
export interface SpineAdditionItem {
|
|
4
|
+
label: 'new-addition';
|
|
5
|
+
prefix: SpineIdPrefix;
|
|
6
|
+
description: string;
|
|
7
|
+
rationale: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SpineRelationItem {
|
|
10
|
+
label: 'strengthens' | 'weakens' | 'contradicts';
|
|
11
|
+
existingId: string;
|
|
12
|
+
existingDescription: string;
|
|
13
|
+
description: string;
|
|
14
|
+
rationale: string;
|
|
15
|
+
}
|
|
16
|
+
export type SpineClassifierItem = SpineAdditionItem | SpineRelationItem;
|
|
17
|
+
export interface ClassifierResult {
|
|
18
|
+
items: SpineClassifierItem[];
|
|
19
|
+
rawOutput: string;
|
|
20
|
+
parsed: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function classifyDiff(diff: string, spineContent: string, signal?: AbortSignal): Promise<ClassifierResult>;
|
|
23
|
+
export declare function parseClassifierOutput(raw: string): ClassifierResult;
|
|
24
|
+
export declare const MAX_DESCRIPTION_LEN = 120;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type SpineSectionName = 'Invariants' | 'Explicitly Rejected Patterns' | 'Taste Calls Made';
|
|
2
|
+
export type SpineIdPrefix = 'INV' | 'REJ' | 'TST';
|
|
3
|
+
export interface SpineEntry {
|
|
4
|
+
id: string;
|
|
5
|
+
date: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SpineSection {
|
|
10
|
+
name: SpineSectionName;
|
|
11
|
+
prefix: SpineIdPrefix;
|
|
12
|
+
entries: SpineEntry[];
|
|
13
|
+
}
|
|
14
|
+
export interface SpineDocument {
|
|
15
|
+
sections: SpineSection[];
|
|
16
|
+
trailer: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseSpine(content: string): SpineDocument;
|
|
19
|
+
export declare function serializeSpine(doc: SpineDocument): string;
|
|
20
|
+
export declare function nextId(doc: SpineDocument, prefix: SpineIdPrefix): string;
|
|
21
|
+
export declare function readSpine(repoRoot: string): SpineDocument | null;
|
|
22
|
+
export declare function writeSpine(repoRoot: string, doc: SpineDocument): void;
|
|
23
|
+
export declare function sectionForPrefix(doc: SpineDocument, prefix: SpineIdPrefix): SpineSection;
|
|
24
|
+
export declare function addEntry(doc: SpineDocument, prefix: SpineIdPrefix, sessionId: string, description: string, date?: string): string;
|
|
25
|
+
export declare function findEntry(doc: SpineDocument, id: string): SpineEntry | undefined;
|