@fastagent-sh/fastagent 0.12.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/LICENSE +21 -0
- package/README.md +214 -0
- package/dist/agent.d.ts +72 -0
- package/dist/agent.js +14 -0
- package/dist/channels/body.d.ts +9 -0
- package/dist/channels/body.js +29 -0
- package/dist/channels/github/github.d.ts +31 -0
- package/dist/channels/github/github.js +80 -0
- package/dist/channels/github/scaffold/channel.ts +25 -0
- package/dist/channels/http.d.ts +13 -0
- package/dist/channels/http.js +161 -0
- package/dist/channels/respond.d.ts +5 -0
- package/dist/channels/respond.js +3 -0
- package/dist/channels/telegram/context-buffer.d.ts +59 -0
- package/dist/channels/telegram/context-buffer.js +139 -0
- package/dist/channels/telegram/invoke-turn.d.ts +53 -0
- package/dist/channels/telegram/invoke-turn.js +127 -0
- package/dist/channels/telegram/parse.d.ts +160 -0
- package/dist/channels/telegram/parse.js +153 -0
- package/dist/channels/telegram/preview.d.ts +22 -0
- package/dist/channels/telegram/preview.js +266 -0
- package/dist/channels/telegram/register-webhook.d.ts +13 -0
- package/dist/channels/telegram/register-webhook.js +73 -0
- package/dist/channels/telegram/scaffold/channel.ts +25 -0
- package/dist/channels/telegram/scaffold/telegram-send.ts +107 -0
- package/dist/channels/telegram/state.d.ts +9 -0
- package/dist/channels/telegram/state.js +58 -0
- package/dist/channels/telegram/telegram-api.d.ts +77 -0
- package/dist/channels/telegram/telegram-api.js +345 -0
- package/dist/channels/telegram/telegram.d.ts +35 -0
- package/dist/channels/telegram/telegram.js +352 -0
- package/dist/channels/telegram/turn-queue.d.ts +21 -0
- package/dist/channels/telegram/turn-queue.js +47 -0
- package/dist/channels/telegram/turn-store.d.ts +38 -0
- package/dist/channels/telegram/turn-store.js +150 -0
- package/dist/cli-auth.d.ts +24 -0
- package/dist/cli-auth.js +30 -0
- package/dist/cli-models.d.ts +11 -0
- package/dist/cli-models.js +20 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1288 -0
- package/dist/collect.d.ts +20 -0
- package/dist/collect.js +27 -0
- package/dist/core.d.ts +10 -0
- package/dist/core.js +8 -0
- package/dist/deploy/container.d.ts +56 -0
- package/dist/deploy/container.js +169 -0
- package/dist/deploy/fly/plan.d.ts +65 -0
- package/dist/deploy/fly/plan.js +142 -0
- package/dist/deploy/fly/run.d.ts +51 -0
- package/dist/deploy/fly/run.js +89 -0
- package/dist/deploy/preflight.d.ts +59 -0
- package/dist/deploy/preflight.js +191 -0
- package/dist/deploy/railway/plan.d.ts +48 -0
- package/dist/deploy/railway/plan.js +91 -0
- package/dist/deploy/railway/run.d.ts +81 -0
- package/dist/deploy/railway/run.js +176 -0
- package/dist/deploy/runner.d.ts +18 -0
- package/dist/deploy/runner.js +25 -0
- package/dist/deploy/secrets.d.ts +49 -0
- package/dist/deploy/secrets.js +88 -0
- package/dist/dev-supervisor.d.ts +14 -0
- package/dist/dev-supervisor.js +158 -0
- package/dist/engines/pi/auth.d.ts +17 -0
- package/dist/engines/pi/auth.js +118 -0
- package/dist/engines/pi/channel.d.ts +31 -0
- package/dist/engines/pi/channel.js +113 -0
- package/dist/engines/pi/chat.d.ts +19 -0
- package/dist/engines/pi/chat.js +200 -0
- package/dist/engines/pi/config.d.ts +110 -0
- package/dist/engines/pi/config.js +285 -0
- package/dist/engines/pi/create.d.ts +127 -0
- package/dist/engines/pi/create.js +222 -0
- package/dist/engines/pi/definition.d.ts +72 -0
- package/dist/engines/pi/definition.js +129 -0
- package/dist/engines/pi/harness.d.ts +50 -0
- package/dist/engines/pi/harness.js +41 -0
- package/dist/engines/pi/invoke.d.ts +28 -0
- package/dist/engines/pi/invoke.js +298 -0
- package/dist/engines/pi/login.d.ts +51 -0
- package/dist/engines/pi/login.js +125 -0
- package/dist/engines/pi/models.d.ts +41 -0
- package/dist/engines/pi/models.js +76 -0
- package/dist/engines/pi/report.d.ts +13 -0
- package/dist/engines/pi/report.js +21 -0
- package/dist/engines/pi/sessions.d.ts +15 -0
- package/dist/engines/pi/sessions.js +130 -0
- package/dist/engines/pi/tool-context.d.ts +17 -0
- package/dist/engines/pi/tool-context.js +13 -0
- package/dist/engines/pi/tool.d.ts +45 -0
- package/dist/engines/pi/tool.js +85 -0
- package/dist/engines/pi/wake-tool.d.ts +20 -0
- package/dist/engines/pi/wake-tool.js +110 -0
- package/dist/engines/pi/workspace.d.ts +53 -0
- package/dist/engines/pi/workspace.js +70 -0
- package/dist/env.d.ts +24 -0
- package/dist/env.js +57 -0
- package/dist/github.d.ts +3 -0
- package/dist/github.js +2 -0
- package/dist/host/node.d.ts +41 -0
- package/dist/host/node.js +50 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/invoke-stream.d.ts +10 -0
- package/dist/invoke-stream.js +26 -0
- package/dist/loader.d.ts +38 -0
- package/dist/loader.js +69 -0
- package/dist/log.d.ts +26 -0
- package/dist/log.js +51 -0
- package/dist/observe.d.ts +12 -0
- package/dist/observe.js +44 -0
- package/dist/pi.d.ts +16 -0
- package/dist/pi.js +12 -0
- package/dist/proxy.d.ts +9 -0
- package/dist/proxy.js +23 -0
- package/dist/runtime.d.ts +26 -0
- package/dist/runtime.js +29 -0
- package/dist/scaffold/add-channel.d.ts +46 -0
- package/dist/scaffold/add-channel.js +227 -0
- package/dist/scaffold/init.d.ts +54 -0
- package/dist/scaffold/init.js +249 -0
- package/dist/scaffold/templates/env.example +24 -0
- package/dist/scaffold/templates/fastagent.config.mjs +19 -0
- package/dist/scaffold/templates/gitignore +8 -0
- package/dist/scaffold/templates/gitignore.agentdir-root +5 -0
- package/dist/scaffold/templates/gitignore.kit +2 -0
- package/dist/scaffold/templates/persona.md +10 -0
- package/dist/scaffold/templates/skills/writing-great-skills/GLOSSARY.md +195 -0
- package/dist/scaffold/templates/skills/writing-great-skills/LICENSE +21 -0
- package/dist/scaffold/templates/skills/writing-great-skills/SKILL.md +82 -0
- package/dist/scaffold/templates/tools/fetch-url.ts +27 -0
- package/dist/scaffold/templates.d.ts +17 -0
- package/dist/scaffold/templates.js +56 -0
- package/dist/scaffold/vendor-skill.d.ts +24 -0
- package/dist/scaffold/vendor-skill.js +157 -0
- package/dist/schedule/audit.d.ts +18 -0
- package/dist/schedule/audit.js +57 -0
- package/dist/schedule/cron.d.ts +7 -0
- package/dist/schedule/cron.js +33 -0
- package/dist/schedule/discover.d.ts +17 -0
- package/dist/schedule/discover.js +64 -0
- package/dist/schedule/schedule.d.ts +35 -0
- package/dist/schedule/schedule.js +23 -0
- package/dist/schedule/scheduler.d.ts +36 -0
- package/dist/schedule/scheduler.js +253 -0
- package/dist/schedule/state.d.ts +14 -0
- package/dist/schedule/state.js +56 -0
- package/dist/schedule/wakeups.d.ts +82 -0
- package/dist/schedule/wakeups.js +196 -0
- package/dist/telegram.d.ts +2 -0
- package/dist/telegram.js +2 -0
- package/dist/tunnel.d.ts +31 -0
- package/dist/tunnel.js +139 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +13 -0
- package/dist/workspace.d.ts +9 -0
- package/dist/workspace.js +45 -0
- package/package.json +97 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init: scaffold a runnable fastagent workspace, offline. Default = a COMPLETE agent (persona.md +
|
|
3
|
+
* the writing-great-skills skill + a fetch-url code tool + fastagent.config.mjs + package.json +
|
|
4
|
+
* .gitignore); `--minimal` drops the code tool and package.json. persona.md is the agent's identity
|
|
5
|
+
* (prompt segment ①); an existing AGENTS.md is never written or touched — it is project context (②),
|
|
6
|
+
* kept as-is. skills/ and tools/ are the agent's self-editable capabilities (re-read each turn).
|
|
7
|
+
*
|
|
8
|
+
* Layout (the jurisdiction rule — core.md scenario grid): the agent kit goes FLAT into `dir` ("a
|
|
9
|
+
* directory is an agent") UNLESS an existing system already CLAIMS the tree — a toolchain config that
|
|
10
|
+
* sweeps files by pattern (tsconfig/framework configs), a deploy manifest (Dockerfile/fly/railway/…),
|
|
11
|
+
* or fastagent's own convention names already occupied (non-empty tools//channels//skills/). Any such
|
|
12
|
+
* signal → the kit defaults into `./agent` (its own namespace; `config.agentDir` points there), so the
|
|
13
|
+
* host's toolchain and the agent's surface never sweep each other. {@link detectHostSignals} detects;
|
|
14
|
+
* the CLI decides (flags override) and reports the reason.
|
|
15
|
+
*
|
|
16
|
+
* Scope: init is best-effort atomic for ORDINARY inputs — it never overwrites existing files,
|
|
17
|
+
* preflights non-directory scaffold parents, and rolls back a partial write (one exception: the
|
|
18
|
+
* .gitignore APPEND is not rolled back — idempotent, harmless residue). It does not defend against
|
|
19
|
+
* every pathological target state (TOCTOU, FIFOs, disk-full): recover by delete-and-retry.
|
|
20
|
+
*
|
|
21
|
+
* Sibling scaffold modules: add-channel.ts (`add <channel>`), vendor-skill.ts (`add skill`). The files
|
|
22
|
+
* this module writes are real templates under templates/, read through templates.ts.
|
|
23
|
+
*/
|
|
24
|
+
import { access, appendFile, lstat, mkdir, readdir, rm, writeFile } from "node:fs/promises";
|
|
25
|
+
import { dirname, join, relative } from "node:path";
|
|
26
|
+
import { WORKSPACE_CONFIG_NAMES } from "../engines/pi/config.js";
|
|
27
|
+
import { detectRuntime, readPackageJson } from "../runtime.js";
|
|
28
|
+
import { loadRootIgnore } from "../workspace.js";
|
|
29
|
+
import { baseTemplate, configTemplate, packageJson, personaTemplate, toPackageName } from "./templates.js";
|
|
30
|
+
import { fastagentVersion } from "../version.js";
|
|
31
|
+
/** Filename marks of a system that claims files by pattern (a build toolchain — F2 in the jurisdiction
|
|
32
|
+
* rule). Not JS-only: a Python/Go/Rust/JVM/Ruby/PHP project's build system claims its tree exactly the
|
|
33
|
+
* same way — an AGENTS.md-carrying Go repo must not get a flat kit (with a package.json!) in its root.
|
|
34
|
+
* Deliberately absent: `Makefile` (too generic — notes/dotfiles repos carry one without a toolchain). */
|
|
35
|
+
const TOOLCHAIN_RE = /^(tsconfig\.json|(next|vite|astro|svelte|nuxt|remix|webpack|rollup)\.config\.[cm]?[jt]s|go\.mod|Cargo\.toml|pyproject\.toml|setup\.py|requirements\.txt|Gemfile|pom\.xml|build\.gradle(\.kts)?|composer\.json|CMakeLists\.txt)$/;
|
|
36
|
+
/** Filename marks of a deploy manifest — the tree ships as a non-agent unit (F4). */
|
|
37
|
+
const DEPLOY_RE = /^(Dockerfile|fly\.toml|railway\.toml|vercel\.json|netlify\.toml)$/;
|
|
38
|
+
/**
|
|
39
|
+
* Jurisdiction signals: evidence that an existing system already claims this tree, so a flat agent kit
|
|
40
|
+
* would put each side's files under the other's jurisdiction (host tsc sweeps agent .ts; fastagent
|
|
41
|
+
* scans host tools/). Three classes, derived from the actual failure modes — a toolchain config, a
|
|
42
|
+
* deploy manifest, or fastagent's convention names already occupied. Any hit → the kit defaults into
|
|
43
|
+
* `./agent`. Deliberately NOT signals: "dir is non-empty", "has package.json", "has src/" — markdown
|
|
44
|
+
* and loose scripts are claimed by nobody, and "a directory is an agent" stays the default. Known
|
|
45
|
+
* tradeoff, decided for visibility: a HAND-BUILT agent dir (skills//tools/ authored for the agent, no
|
|
46
|
+
* config yet) also hits the occupation signal and defaults to ./agent — wrong for that case, but the
|
|
47
|
+
* reason is printed and `--flat` overrides; the reverse default would silently mis-scan a host's dirs.
|
|
48
|
+
*/
|
|
49
|
+
export async function detectHostSignals(dir) {
|
|
50
|
+
// Only ENOENT/ENOTDIR mean "nothing there" (fresh dir → flat). A real IO failure (EACCES…) must
|
|
51
|
+
// surface, not silently decide the layout — init is about to write into this directory anyway.
|
|
52
|
+
const absent = (err) => {
|
|
53
|
+
const code = err.code;
|
|
54
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
55
|
+
return [];
|
|
56
|
+
throw err;
|
|
57
|
+
};
|
|
58
|
+
const signals = [];
|
|
59
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(absent);
|
|
60
|
+
for (const e of entries) {
|
|
61
|
+
if (e.isFile() && (TOOLCHAIN_RE.test(e.name) || DEPLOY_RE.test(e.name)))
|
|
62
|
+
signals.push(e.name);
|
|
63
|
+
}
|
|
64
|
+
for (const name of ["tools", "channels", "skills"]) {
|
|
65
|
+
const st = await lstat(join(dir, name)).catch((err) => {
|
|
66
|
+
absent(err);
|
|
67
|
+
return undefined;
|
|
68
|
+
});
|
|
69
|
+
// Dotfiles (.DS_Store, .gitkeep) are not agent surface — the loaders would never scan them, so
|
|
70
|
+
// they must not count as "occupied" either (the signal mirrors what fastagent would actually scan).
|
|
71
|
+
const occupants = st?.isDirectory()
|
|
72
|
+
? (await readdir(join(dir, name)).catch(absent)).filter((f) => !f.startsWith("."))
|
|
73
|
+
: [];
|
|
74
|
+
if (occupants.length > 0)
|
|
75
|
+
signals.push(`${name}/`);
|
|
76
|
+
}
|
|
77
|
+
return signals.sort();
|
|
78
|
+
}
|
|
79
|
+
/** The `cd` target to show in `init`'s next-steps: the relative path when the target is inside `cwd`,
|
|
80
|
+
* the absolute path when it climbs out (a `../../..` is noise), or undefined when already in `cwd`. */
|
|
81
|
+
export function nextStepCd(cwd, dir) {
|
|
82
|
+
const rel = relative(cwd, dir);
|
|
83
|
+
if (rel === "")
|
|
84
|
+
return undefined;
|
|
85
|
+
// "Climbs out" is a path-SEGMENT check — rel is ".." or starts with "../" (or "..\" on Windows). A
|
|
86
|
+
// bare startsWith("..") would wrongly flag an in-cwd directory literally named "..agent".
|
|
87
|
+
const escapes = rel === ".." || /^\.\.[/\\]/.test(rel);
|
|
88
|
+
return escapes ? dir : rel;
|
|
89
|
+
}
|
|
90
|
+
/** Does a path exist? (async; shared with the sibling scaffold modules). */
|
|
91
|
+
export async function exists(p) {
|
|
92
|
+
return access(p).then(() => true, () => false);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Scaffold a runnable workspace into {@link dir} (created if missing). Default is a complete agent
|
|
96
|
+
* (persona.md + the writing-great-skills skill + a code tool + package.json); `--minimal` drops the
|
|
97
|
+
* code tool and package.json. The kit goes flat into `dir`, or into {@link ScaffoldOptions.agentDir}
|
|
98
|
+
* (config at the root pointing there). Refuses only an existing fastagent.config.* (the ownership
|
|
99
|
+
* marker — already a workspace); every other pre-existing file (AGENTS.md, .gitignore, package.json)
|
|
100
|
+
* is kept, never overwritten — an existing AGENTS.md is the project's context, adopted as-is.
|
|
101
|
+
*/
|
|
102
|
+
export async function scaffoldWorkspace(dir, options = {}) {
|
|
103
|
+
const minimal = options.minimal ?? false;
|
|
104
|
+
const kit = options.agentDir ?? "."; // where the agent's own surface lands
|
|
105
|
+
const skill = (name) => ({
|
|
106
|
+
rel: join(kit, "skills", "writing-great-skills", name),
|
|
107
|
+
content: baseTemplate(`skills/writing-great-skills/${name}`),
|
|
108
|
+
});
|
|
109
|
+
const files = [
|
|
110
|
+
// ① identity. AGENTS.md is deliberately NOT scaffolded: a fresh agent has no project context, and
|
|
111
|
+
// an existing repo already owns its AGENTS.md (kept untouched, read as ② context from cwd).
|
|
112
|
+
{ rel: join(kit, "persona.md"), content: personaTemplate(options.agentDir) },
|
|
113
|
+
// The example skill: how to author skills well — the core of self-iteration. Markdown, so it
|
|
114
|
+
// ships in --minimal too. Vendored verbatim from mattpocock/skills (MIT); LICENSE sits beside it.
|
|
115
|
+
skill("SKILL.md"),
|
|
116
|
+
skill("GLOSSARY.md"),
|
|
117
|
+
skill("LICENSE"),
|
|
118
|
+
// Run-root pieces: the config (carrying agentDir when the kit is a subdir), secrets hygiene, env template.
|
|
119
|
+
{ rel: "fastagent.config.mjs", content: configTemplate(options.agentDir) },
|
|
120
|
+
{ rel: ".gitignore", content: baseTemplate(options.agentDir ? "gitignore.agentdir-root" : "gitignore") },
|
|
121
|
+
{ rel: ".env.example", content: baseTemplate("env.example") },
|
|
122
|
+
];
|
|
123
|
+
if (!minimal) {
|
|
124
|
+
files.push({ rel: join(kit, "tools", "fetch-url.ts"), content: baseTemplate("tools/fetch-url.ts") },
|
|
125
|
+
// The kit's own manifest: in the agentDir layout the agent self-contains its deps, so the host's
|
|
126
|
+
// package.json/lockfile is never touched. The name says WHOSE agent it is (the workspace's), not
|
|
127
|
+
// which subdirectory it happens to live in.
|
|
128
|
+
{
|
|
129
|
+
rel: join(kit, "package.json"),
|
|
130
|
+
content: packageJson(options.agentDir ? `${toPackageName(dir)}-agent` : toPackageName(dir), await fastagentVersion()),
|
|
131
|
+
}, ...(options.agentDir ? [{ rel: join(kit, ".gitignore"), content: baseTemplate("gitignore.kit") }] : []));
|
|
132
|
+
}
|
|
133
|
+
// Guard on the ownership marker: a config means "already a fastagent workspace". Fail visibly
|
|
134
|
+
// rather than double-initialize. (AGENTS.md is NOT a marker — it is context, adopted untouched.)
|
|
135
|
+
const conflicts = [];
|
|
136
|
+
for (const name of WORKSPACE_CONFIG_NAMES)
|
|
137
|
+
if (await exists(join(dir, name)))
|
|
138
|
+
conflicts.push(name);
|
|
139
|
+
if (conflicts.length > 0) {
|
|
140
|
+
throw new Error(`"${dir}" already has ${conflicts.join(", ")} — already a fastagent workspace`);
|
|
141
|
+
}
|
|
142
|
+
// Never merge the kit into an existing NON-EMPTY directory (a host repo may own an unrelated `agent/`
|
|
143
|
+
// — common in AI products): wx would keep its files, but persona.md/skills/ landing inside someone
|
|
144
|
+
// else's code dir is a silent mix. Refuse with the way out. Dotfiles (.DS_Store, .gitkeep) don't
|
|
145
|
+
// count — same rule as detectHostSignals' occupation check. A SYMLINKED kit path slips past this
|
|
146
|
+
// readdir (it follows links) — deliberate: the parent preflight below lstat-rejects it before any write.
|
|
147
|
+
if (options.agentDir) {
|
|
148
|
+
const occupants = (await readdir(join(dir, kit)).catch(() => [])).filter((f) => !f.startsWith("."));
|
|
149
|
+
if (occupants.length > 0) {
|
|
150
|
+
throw new Error(`"${kit}" already exists and is not empty — if it is unrelated to the agent, pick another name ` +
|
|
151
|
+
`(--agent-dir <name>) or go flat (--flat); to adopt it as the kit, empty it first`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Was the target non-empty BEFORE we wrote anything? (missing dir = empty).
|
|
155
|
+
const intoNonEmpty = (await readdir(dir).catch(() => [])).length > 0;
|
|
156
|
+
// Preflight scaffold parent dirs: a pre-existing non-directory there would make mkdir fail mid-loop
|
|
157
|
+
// AFTER the first write, leaving a half-scaffold. Detect it before any write (lstat, not stat: a
|
|
158
|
+
// symlinked parent must be rejected, not followed — it would write outside the workspace).
|
|
159
|
+
const parents = new Set();
|
|
160
|
+
for (const file of files) {
|
|
161
|
+
let p = dirname(file.rel);
|
|
162
|
+
while (p !== "." && p !== "") {
|
|
163
|
+
parents.add(p);
|
|
164
|
+
p = dirname(p);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
for (const rel of parents) {
|
|
168
|
+
const st = await lstat(join(dir, rel)).catch(() => undefined);
|
|
169
|
+
if (st && !st.isDirectory()) {
|
|
170
|
+
throw new Error(`cannot scaffold: "${rel}" exists and is not a directory (a regular file or symlink) — remove it, or init elsewhere`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
await mkdir(dir, { recursive: true });
|
|
174
|
+
const created = [];
|
|
175
|
+
const skipped = [];
|
|
176
|
+
const patched = [];
|
|
177
|
+
const warnings = [];
|
|
178
|
+
// ONE rollback scope: any failure removes files written THIS run (guard + wx guarantee they are
|
|
179
|
+
// ours), so scaffoldWorkspace is atomic — except the .gitignore APPEND below, which is not rolled
|
|
180
|
+
// back (the residue is idempotent, harmless ignore lines; removing someone else's file's tail is riskier).
|
|
181
|
+
try {
|
|
182
|
+
for (const file of files) {
|
|
183
|
+
const abs = join(dir, file.rel);
|
|
184
|
+
await mkdir(dirname(abs), { recursive: true });
|
|
185
|
+
try {
|
|
186
|
+
await writeFile(abs, file.content, { flag: "wx" }); // wx: never clobber
|
|
187
|
+
created.push(file.rel);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
if (error.code === "EEXIST")
|
|
191
|
+
skipped.push(file.rel);
|
|
192
|
+
else
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Ignore ownership follows layout jurisdiction. Run-root state/secrets live at `dir`, so the ROOT
|
|
197
|
+
// .gitignore owns `.env` + `.fastagent`. The kit's npm deps live where the kit lives: flat → root
|
|
198
|
+
// `node_modules/`; agentDir → `<agentDir>/.gitignore` owns its own `node_modules/`. This avoids
|
|
199
|
+
// patching a host repo's root ignore with agent-internal dependency paths while still preventing the
|
|
200
|
+
// post-init 25k-file untracked flood.
|
|
201
|
+
const coveredBy = (ig, p) => (ig?.ignores(p) ?? false) || (ig?.ignores(`${p}/`) ?? false);
|
|
202
|
+
const rootIgnore = await loadRootIgnore(dir);
|
|
203
|
+
const rootRequired = [
|
|
204
|
+
{ path: ".env", pattern: ".env" },
|
|
205
|
+
{ path: ".fastagent", pattern: ".fastagent" },
|
|
206
|
+
...(!minimal && !options.agentDir ? [{ path: "node_modules", pattern: "node_modules/" }] : []),
|
|
207
|
+
];
|
|
208
|
+
const rootNeed = rootRequired.filter((e) => !coveredBy(rootIgnore, e.path));
|
|
209
|
+
if (rootNeed.length > 0) {
|
|
210
|
+
await appendFile(join(dir, ".gitignore"), `\n# fastagent\n${rootNeed.map((e) => e.pattern).join("\n")}\n`);
|
|
211
|
+
patched.push(".gitignore");
|
|
212
|
+
// A .fastagentignore is applied LAST and can re-include what .gitignore excludes — the append
|
|
213
|
+
// cannot fix that, so re-check and keep it a visible warning instead of false assurance.
|
|
214
|
+
const after = await loadRootIgnore(dir);
|
|
215
|
+
const still = rootNeed.filter((e) => !coveredBy(after, e.path)).map((e) => e.path);
|
|
216
|
+
if (still.length > 0) {
|
|
217
|
+
warnings.push(`your .gitignore/.fastagentignore does not exclude ${still.map((s) => `"${s}"`).join(", ")} — a deploy that copies the directory may ship secrets/state`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (!minimal && options.agentDir) {
|
|
221
|
+
// Deliberately checks ONLY the kit's own ignore, not the root: the kit is the portable agent
|
|
222
|
+
// directory, and its dependency ignore must travel WITH it (a fresh kit .gitignore carries
|
|
223
|
+
// node_modules/ unconditionally for the same reason) — a root-level `node_modules/` that happens
|
|
224
|
+
// to cover it today doesn't survive the kit being copied out of the host repo.
|
|
225
|
+
const kitIgnore = await loadRootIgnore(join(dir, kit));
|
|
226
|
+
if (!coveredBy(kitIgnore, "node_modules")) {
|
|
227
|
+
const rel = join(kit, ".gitignore");
|
|
228
|
+
await appendFile(join(dir, rel), `\n# fastagent\nnode_modules/\n`);
|
|
229
|
+
patched.push(rel);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// A kept package.json won't carry the tool's deps — the example tool would not resolve. The install
|
|
233
|
+
// command matches the workspace's runtime (bun.lock → bun add).
|
|
234
|
+
const keptPkg = join(kit, "package.json");
|
|
235
|
+
if (!minimal && skipped.includes(keptPkg)) {
|
|
236
|
+
const kitAbs = join(dir, kit);
|
|
237
|
+
const add = detectRuntime(kitAbs, await readPackageJson(kitAbs)).runtime === "bun" ? "bun add" : "npm install";
|
|
238
|
+
warnings.push(`kept the existing ${keptPkg} — run \`${add} @fastagent-sh/fastagent\` there so the example tool resolves`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
// Best-effort rollback of a partial scaffold: a file that won't delete is left behind (the original
|
|
243
|
+
// error below is the one worth surfacing — a cleanup failure must not mask it).
|
|
244
|
+
for (const rel of created.reverse())
|
|
245
|
+
await rm(join(dir, rel), { force: true }).catch(() => { });
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
return { dir, complete: !minimal, agentDir: options.agentDir, created, skipped, patched, intoNonEmpty, warnings };
|
|
249
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Environment for this agent. Copy to .env (gitignored) and uncomment what you need.
|
|
2
|
+
# Everything here is OPTIONAL — the defaults work without a .env.
|
|
3
|
+
|
|
4
|
+
# --- Model auth ---
|
|
5
|
+
# Pick auth once: `fastagent login` (a subscription/OAuth provider like openai-codex, or an API key),
|
|
6
|
+
# or set a provider API key here — the variable name is provider-specific (e.g. OPENAI_API_KEY,
|
|
7
|
+
# ANTHROPIC_API_KEY). `fastagent dev` then lets you choose a model from whatever you're logged into.
|
|
8
|
+
# OPENAI_API_KEY=
|
|
9
|
+
# ANTHROPIC_API_KEY=
|
|
10
|
+
|
|
11
|
+
# --- Model selection (overrides fastagent.config) ---
|
|
12
|
+
# Precedence: --model flag > FASTAGENT_MODEL > config. `fastagent dev` writes your first-run pick to
|
|
13
|
+
# fastagent.config; set it here to override per-environment.
|
|
14
|
+
# FASTAGENT_MODEL=openai-codex/gpt-5.5
|
|
15
|
+
|
|
16
|
+
# --- Serving (fastagent start) ---
|
|
17
|
+
# Port precedence: --port > PORT > config.http.port > 8787
|
|
18
|
+
# PORT=8787
|
|
19
|
+
# Machine-state root: sessions, auth.json, and channel state all derive from it.
|
|
20
|
+
# Default: <dir>/.fastagent. Point it at a mounted volume so a redeploy that replaces the
|
|
21
|
+
# directory keeps conversations and credentials.
|
|
22
|
+
# FASTAGENT_STATE_DIR=/data/fastagent
|
|
23
|
+
# Override just the sessions path (default: <state root>/sessions):
|
|
24
|
+
# FASTAGENT_SESSIONS_DIR=/data/sessions
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// fastagent.config.mjs — deployment choices only (model / http; code tools auto-discover from tools/).
|
|
2
|
+
// Your agent's identity lives in persona.md; its capabilities in skills/ + tools/ — never here.
|
|
3
|
+
// An AGENTS.md at the workspace root (yours or the host repo's) is read as project context.
|
|
4
|
+
// Model precedence: `--model` flag > FASTAGENT_MODEL env > this default.
|
|
5
|
+
// No model is preset: `fastagent dev` prompts you to pick one from the providers you're logged into
|
|
6
|
+
// (run `fastagent login` first) and writes your choice below. Or set it by hand to a "provider/modelId"
|
|
7
|
+
// you have access to (`fastagent models` lists them).
|
|
8
|
+
export default {
|
|
9
|
+
// model: "openai-codex/gpt-5.5",
|
|
10
|
+
http: { port: 8787 },
|
|
11
|
+
// selfSchedule: true, // mount the built-in `wake` tool: the agent schedules its own follow-up turns
|
|
12
|
+
// // ("check the deploy in 10 min"). Cron jobs need no opt-in — drop a schedules/<name>.ts.
|
|
13
|
+
// deploy: what the agent needs on the box (so `fastagent deploy` doesn't need a hand-written Dockerfile
|
|
14
|
+
// or hand-set host variables). Uncomment as needed:
|
|
15
|
+
// deploy: {
|
|
16
|
+
// secrets: ["GH_TOKEN"], // extra secret env vars your tools use — deploy carries them from your local env
|
|
17
|
+
// apt: ["git"], // extra apt packages baked into the image (git, ripgrep, …; default repos only)
|
|
18
|
+
// },
|
|
19
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Persona
|
|
2
|
+
|
|
3
|
+
You are this workspace's agent. This file is your identity — it overrides the engine's default identity line, and it is re-read every turn along with the rest of your definition (`skills/` — capabilities you load when a task calls for them; `tools/` — code tools your author added, in the same directory as this file). An edit to any of them takes effect on your next message, no restart. Your `read` / `write` / `edit` / `bash` tools operate at the workspace root you were started in; if the workspace has an `AGENTS.md`, it is project context — read it to learn the project's conventions.
|
|
4
|
+
|
|
5
|
+
You can improve yourself. When a task reveals something durable — a repeatable process, a standing preference, a hard-won fact — write it into your definition instead of losing it:
|
|
6
|
+
|
|
7
|
+
- A repeatable process or capability → a new skill beside this file: `skills/<name>/SKILL.md`. Read `skills/writing-great-skills/SKILL.md` first; it is the guide to authoring skills well.
|
|
8
|
+
- A standing instruction or fact → edit this file.
|
|
9
|
+
|
|
10
|
+
Keep both lean: include only what changes your behavior, and delete what no longer earns its place.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Glossary — Building Great Skills
|
|
2
|
+
|
|
3
|
+
The domain model for what makes a skill great. A skill exists to wrangle determinism out of a stochastic system; the root virtue is **Predictability**, and every term below is a lever on it. This is the disclosed reference for [`writing-great-skills`](SKILL.md).
|
|
4
|
+
|
|
5
|
+
The terms are grouped by axis: **Invocation** (how a skill is reached), **Information Hierarchy** (how its content is arranged), **Steering** (how the agent's runtime behaviour is shaped), and **Pruning** (how it is kept lean). Each **failure mode** lives beside the lever that cures it, tagged _failure mode_.
|
|
6
|
+
|
|
7
|
+
**Bold terms** in any definition are themselves defined in this glossary; find them by their heading.
|
|
8
|
+
|
|
9
|
+
## Predictability
|
|
10
|
+
|
|
11
|
+
The degree to which a skill makes the agent behave the same _way_ on every run — the same process, not the same output (a brainstorming skill should _predictably_ diverge; its tokens vary, its behaviour doesn't). The root virtue every other term serves — cost and maintainability are symptoms of it, not rivals.
|
|
12
|
+
|
|
13
|
+
_Avoid_: consistency, reliability, robustness, output-determinism
|
|
14
|
+
|
|
15
|
+
## Invocation
|
|
16
|
+
|
|
17
|
+
How a skill is reached — and the two loads you pay for the choice.
|
|
18
|
+
|
|
19
|
+
### Model-Invoked
|
|
20
|
+
|
|
21
|
+
A skill that keeps its **description** field, so the agent can see it and fire it autonomously — and the human can still type its name, so model-invocation always _includes_ user reach. There is no model-only state: a description only ever _adds_ agent discovery, never removes the human's. Pays a permanent **context load** on every turn in exchange for that discoverability. Reachable by other skills, because the description that makes it agent-discoverable makes it invocable. A model-invoked skill whose content is all **reference** is also one home for shared reference: another skill can invoke it, so reference needed by several skills lives in one place. Pick model-invocation only when the agent must reach the skill on its own; if it never fires except by hand, drop the description and pay no context load.
|
|
22
|
+
|
|
23
|
+
_Avoid_: ability, tool, capability
|
|
24
|
+
|
|
25
|
+
### User-Invoked
|
|
26
|
+
|
|
27
|
+
A skill with its **description** stripped — invisible to the agent and reachable only by the human typing its name (user-_only_, where **model-invoked** is user-_and-agent_). Trades agent-discoverability for zero **context load**. Because it has no description, nothing but the human can reach it: no other skill can fire it.
|
|
28
|
+
|
|
29
|
+
_Avoid_: procedure, workflow, command
|
|
30
|
+
|
|
31
|
+
### Description
|
|
32
|
+
|
|
33
|
+
The skill's machine-readable trigger, and the one **context pointer** a **model-invoked** skill is forced to keep loaded at all times. Its mere presence _is_ the invocation axis: keep it and the skill is model-invoked (and reachable by other skills); delete it and the skill is **user-invoked**, reachable only by the human. The source of a model-invoked skill's **context load**.
|
|
34
|
+
|
|
35
|
+
_Avoid_: frontmatter, summary
|
|
36
|
+
|
|
37
|
+
### Context Pointer
|
|
38
|
+
|
|
39
|
+
A reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. The **description** is the top-level context pointer (context window → skill); pointers to disclosed files are the same object one level down. Its wording, not the target, decides _when_ the agent reaches — and _how reliably_. A must-have target behind a weakly worded pointer is a variance bug: fix the wording first, and inline the material only if sharpening fails.
|
|
40
|
+
|
|
41
|
+
_Avoid_: link, reference, import
|
|
42
|
+
|
|
43
|
+
### Context Load
|
|
44
|
+
|
|
45
|
+
The cost a **model-invoked** skill imposes on the agent's context window — its **description**, always loaded, spending both tokens and attention. What **user-invoked** skills escape by having no description, and the brake on splitting into more model-invoked skills.
|
|
46
|
+
|
|
47
|
+
_Avoid_: token cost, context bloat
|
|
48
|
+
|
|
49
|
+
### Cognitive Load
|
|
50
|
+
|
|
51
|
+
The cost a **user-invoked** skill imposes on the human — what they must hold in their head: which skills exist and when to reach for each (the human is the index). What **model-invocation** removes by being agent-discoverable, and the brake on splitting into more user-invoked skills. Not a cost to minimise: it is the price of human agency, the reason some skills stay user-invoked. Spend it where human judgement matters; remove it where it does not.
|
|
52
|
+
|
|
53
|
+
_Avoid_: human index, burden, overhead
|
|
54
|
+
|
|
55
|
+
### Router Skill
|
|
56
|
+
|
|
57
|
+
A **user-invoked** skill whose job is to point at your other user-invoked skills — naming each and when to reach for it — so the human has one skill to remember instead of many. It can only hint, never fire them: user-invoked skills have no **description**, so nothing but the human can reach them. The cure for **cognitive load** when user-invoked skills multiply.
|
|
58
|
+
|
|
59
|
+
_Avoid_: dispatcher, menu, registry, index, router procedure
|
|
60
|
+
|
|
61
|
+
### Granularity
|
|
62
|
+
|
|
63
|
+
How finely you divide skills. Finer division spends one of the two loads: more **model-invoked** skills spend **context load** (more descriptions crowding the window and competing for attention); more **user-invoked** skills spend **cognitive load** (more for the human to remember and reach for). Two cuts guide the division. By **invocation**, split off a model-invoked skill where you have a distinct **leading word** to trigger it — a trigger word you actually use in your prompts. By **sequence**, split a run of **steps** where a step's **post-completion steps** need hiding, since isolating it in its own context clears what follows. Beware the reverse: merging sequences exposes each step's post-completion steps to what follows, inviting premature completion.
|
|
64
|
+
|
|
65
|
+
_Avoid_: chunking, modularity
|
|
66
|
+
|
|
67
|
+
## Information Hierarchy
|
|
68
|
+
|
|
69
|
+
How a skill's content is arranged, and how far down the ladder each piece sits.
|
|
70
|
+
|
|
71
|
+
### Information Hierarchy
|
|
72
|
+
|
|
73
|
+
A skill's content ranked by how immediately the agent needs it — a single ladder, produced by two cuts: in-file or behind a pointer, and step or reference. The rungs:
|
|
74
|
+
|
|
75
|
+
- **Steps** — in-file, primary
|
|
76
|
+
- **Reference**, in-file — secondary
|
|
77
|
+
- **Reference**, disclosed — behind a **context pointer**
|
|
78
|
+
|
|
79
|
+
A skill with no **steps** uses just the bottom two rungs — often a legitimately flat peer-set (e.g. every rule of a review on one rung), which is a fine arrangement, not a smell. The hierarchy is independent of invocation: a skill can be model- or user-invoked whether it is all steps, all reference, or both. When a skill has steps, in-file reference that should be disclosed buries them and turns attending to them into a coin-flip — a variance lever, not just a legibility one. Keep the top of the ladder legible; push down it whatever you can.
|
|
80
|
+
|
|
81
|
+
_Avoid_: structure, organization, layout
|
|
82
|
+
|
|
83
|
+
### Steps
|
|
84
|
+
|
|
85
|
+
The ordered actions the agent performs — when a skill has them, the primary tier of its content, and the part that earns its place in SKILL.md. Not every skill has steps: a skill can be all steps (`tdd`), all **reference** (a review), or both, independent of invocation. Every step ends on a **completion criterion**, clear or vague.
|
|
86
|
+
|
|
87
|
+
_Avoid_: workflow, instructions, choreography
|
|
88
|
+
|
|
89
|
+
### Reference
|
|
90
|
+
|
|
91
|
+
Material the agent refers to on demand — definitions, facts, parameters, examples, conditional instructions. When a skill has **steps** it is secondary to them; when a skill has none it is the entire content; or it lives outside any skill entirely — see **External Reference**. Reached via **context pointers**, and the prime candidate for **progressive disclosure**.
|
|
92
|
+
|
|
93
|
+
_Avoid_: supporting material, docs, background
|
|
94
|
+
|
|
95
|
+
### External Reference
|
|
96
|
+
|
|
97
|
+
**Reference** that lives outside the skill system — a plain file, no **description**, no **steps**, not invocable — that any skill can point at. The home for shared reference that needn't fire on its own, and the only shared home two **user-invoked** skills can use, since neither has a description and so neither can fire the other.
|
|
98
|
+
|
|
99
|
+
_Avoid_: doc, resource, knowledge base
|
|
100
|
+
|
|
101
|
+
### Progressive Disclosure
|
|
102
|
+
|
|
103
|
+
Moving **reference** down the ladder — out of SKILL.md and behind a **context pointer** — so the top stays legible. Not primarily a token optimisation; it is how the **information hierarchy** is protected. Licensed by **branching**: disclose what only some branches need, inline what every path needs, and if a pointer fires unreliably on must-have material, sharpen its wording, and pull it back inline only if that fails.
|
|
104
|
+
|
|
105
|
+
_Avoid_: lazy loading, chunking
|
|
106
|
+
|
|
107
|
+
### Co-location
|
|
108
|
+
|
|
109
|
+
Keeping the material an agent needs at once in one place — a concept's definition, rules, and caveats under a single heading, not scattered across the file — so reading one part brings its neighbours with it. The within-file companion to the **Information Hierarchy**: the hierarchy ranks _how far down_ a piece sits; co-location decides _what sits beside it_ once there. There is no formula for the right format of a body of **reference**; the test is that a skill should read like documentation written for the agent, and grouped material reads that way where scattered material does not. Distinct from **Duplication**: that repeats one meaning in two places, where scattering fragments a single meaning across many.
|
|
110
|
+
|
|
111
|
+
_Avoid_: grouping, clustering, cohesion
|
|
112
|
+
|
|
113
|
+
### Sprawl
|
|
114
|
+
|
|
115
|
+
_Failure mode._ A skill that is simply too long — too many lines in SKILL.md — independent of whether they are stale or repeated. Even an all-live, all-unique skill can sprawl. It costs readability (the agent wades through more before it can act, and attention thins across the excess), maintainability (every extra line is one more to keep **relevant**), and tokens. The cure is the **information hierarchy**: push **reference** down behind **context pointers**, and split by **branch** or sequence so each path carries only what it needs. Distinct from **sediment** (length from stale accumulation) and **duplication** (length from repeated meaning) — sprawl is length itself, whatever its cause.
|
|
116
|
+
|
|
117
|
+
_Avoid_: bloat, length, size, verbosity
|
|
118
|
+
|
|
119
|
+
## Steering
|
|
120
|
+
|
|
121
|
+
The levers that shape the agent's runtime behaviour toward **Predictability**.
|
|
122
|
+
|
|
123
|
+
### Branch
|
|
124
|
+
|
|
125
|
+
A distinct way a skill can be invoked — a case the skill handles — so different runs take different paths through it. A skill with many steps may carry many branches; a linear one has none.
|
|
126
|
+
|
|
127
|
+
_Avoid_: path, case, fork
|
|
128
|
+
|
|
129
|
+
### Leading Word
|
|
130
|
+
|
|
131
|
+
A compact concept — also called a _Leitwort_ — already living in the model's pretraining, that the agent thinks with while running the skill. It encodes a behavioural principle in the fewest possible tokens by invoking priors the model already holds (e.g. _lesson_, _proximal zone of development_, _fog of war_, _tracer bullets_). Repeated as a token, never as a sentence, it accumulates a distributed definition across the skill and anchors a whole region of behaviour. Coining your own works if you define it clearly, but a made-up word recruits no priors — you pay in definition tokens what a pretrained word gives free. Reach for an existing word first.
|
|
132
|
+
|
|
133
|
+
A leading word serves **predictability** twice. In the body it anchors **execution** — the agent reaches for the same behaviour every time the concept appears, and inside flat reference it focuses attention on a class of thing to look for, recruiting the right checks each run. In the **description** it anchors **invocation** — and not only within the skill: when the same word lives in your prompts, your docs, and your codebase, the agent links that shared language to the skill and fires it more reliably. Word a description with the leading words you actually use when you want the skill.
|
|
134
|
+
|
|
135
|
+
_Avoid_: keyword, term, motif
|
|
136
|
+
|
|
137
|
+
### Completion Criterion
|
|
138
|
+
|
|
139
|
+
The condition that tells the agent a unit of work is done — the target it judges against. Two properties make it a lever, not just a quality. Its **clarity** (can the agent tell done from not-done?) resists **premature completion** — a vague bound ("understanding reached") lets the agent declare done and slip to the next step; this axis needs _steps_ to bite, since premature completion is a between-steps failure. Its **demand** (how much it requires) sets **legwork** — "every modified model accounted for" forces thorough work where "produce a change list" does not — and this axis is _not_ step-bound: it can bind a body of flat reference too, which is how a skill with no steps still carries an exhaustiveness bar ("every rule applied"). The strongest criteria are both checkable and exhaustive.
|
|
140
|
+
|
|
141
|
+
_Avoid_: done condition, exit condition, stopping rule
|
|
142
|
+
|
|
143
|
+
### Legwork
|
|
144
|
+
|
|
145
|
+
The work an agent does behind the scenes within a single step — reading files, exploring the codebase, making changes, digging up what it needs rather than offloading to the user. It lives below the step structure: never written as its own step, latent in the wording, controlled by the agent rather than the skill. The within-step counterpart to **post-completion steps**' across-step pull. Raised by a **leading word** (_comprehensive_, _thorough_) or a **completion criterion** that demands the work be exhaustive — including the demand axis applied to flat reference, which is what drives a skill of flat reference to cover all its rungs. Goes thin either when that demand is missing or when **premature completion** cuts the step short.
|
|
146
|
+
|
|
147
|
+
_Avoid_: scope, effort, diligence, coverage
|
|
148
|
+
|
|
149
|
+
### Post-Completion Steps
|
|
150
|
+
|
|
151
|
+
The **steps** that follow the current step. Visible, they pull the agent forward into **premature completion** — the more it sees, the stronger the tug; the defence is to hide them by splitting the sequence of steps into two.
|
|
152
|
+
|
|
153
|
+
_Avoid_: horizon, fog of war, lookahead
|
|
154
|
+
|
|
155
|
+
### Premature Completion
|
|
156
|
+
|
|
157
|
+
_Failure mode._ Ending the current step before it is genuinely done, because the agent's attention slips to being done rather than to the work. A between-steps failure: it needs **steps** to occur — a skill with no steps that quits early isn't premature completion but thin **legwork** under an unmet demand. A tug-of-war between two forces: visible **post-completion steps** (the pull forward) and the **completion criterion**'s clarity (the resistance — a sharp, checkable bar holds; a vague one gives way). Fuzziness is the necessary condition: a sharp bound resists the pull no matter how many later steps are visible, so a step that never rushes needs no defending. Two levers hold a step that does, but reach for them in order: **sharpen the bound first** — it is local and cheap. Only when the criterion is irreducibly fuzzy _and_ you actually observe the rush do you **hide the later steps** — and hiding only works across a real context boundary (a user-invoked hand-off or a subagent dispatch; an inline model-invoked call leaves the later steps in context and clears nothing). One cause of thin legwork, but distinct from it: legwork can be thin even when a step runs to full completion.
|
|
158
|
+
|
|
159
|
+
_Avoid_: premature closure, the rush, rushing, shortcutting
|
|
160
|
+
|
|
161
|
+
## Pruning
|
|
162
|
+
|
|
163
|
+
Keeping a skill lean — each remedy paired with the failure it cures.
|
|
164
|
+
|
|
165
|
+
### Single Source of Truth
|
|
166
|
+
|
|
167
|
+
The desired state where each meaning lives in exactly one authoritative place, so a change to the skill's behaviour is a change in one place. **Duplication** is its violation.
|
|
168
|
+
|
|
169
|
+
_Avoid_: home, canonical location
|
|
170
|
+
|
|
171
|
+
### Duplication
|
|
172
|
+
|
|
173
|
+
_Failure mode._ The same meaning given more than one **single source of truth**. It costs maintenance (change one place, you must change the others), costs tokens, and inflates prominence — repeating a meaning weights it on the ladder past its real rank. The accidental inverse of a **leading word**, which raises attention on purpose by repeating a token, never the meaning.
|
|
174
|
+
|
|
175
|
+
_Avoid_: repetition, redundancy
|
|
176
|
+
|
|
177
|
+
### Relevance
|
|
178
|
+
|
|
179
|
+
Whether a line still bears on what the skill does — the lens for what to keep. A line loses relevance either by never bearing on the task (mere exposition, or a **branch** that should be disclosed) or by going stale: drifting out of date as the behaviour or world it describes changes. Shorter skills are easier to keep relevant, because each line is cheaper to check. Distinct from **no-op**: relevance asks whether a line bears on the task, not whether it changes behaviour.
|
|
180
|
+
|
|
181
|
+
_Avoid_: load-bearing, staleness, freshness
|
|
182
|
+
|
|
183
|
+
### Sediment
|
|
184
|
+
|
|
185
|
+
_Failure mode._ Layers of old content that settle in a skill and are never cleared, because adding feels safe and removing feels risky — so stale and irrelevant lines accumulate and you must core down through them to find what is still live. The default fate of any skill without a pruning discipline; the slow erosion of **relevance**, as opposed to **duplication**'s repeated meaning.
|
|
186
|
+
|
|
187
|
+
_Avoid_: accretion, bloat, cruft, rot
|
|
188
|
+
|
|
189
|
+
### No-Op
|
|
190
|
+
|
|
191
|
+
_Failure mode._ An instruction that changes nothing because the model already does it by default — you pay load to tell the agent what it would do anyway. The test: does a line change behaviour versus the default? A line can be perfectly **relevant** and still be a no-op. The same priors that make a **leading word** free make a no-op worthless.
|
|
192
|
+
|
|
193
|
+
A leading word is a _technique_; No-Op is a _verdict_ on a line — and they cross. A leading word too weak to beat the default is a no-op (_be thorough_ when the agent is already thorough-ish), and the fix is a stronger word that passes the verdict (_relentless_), not a different technique. So the No-Op test — does it change behaviour versus the default? — is also how you grade whether a leading word is earning its repetitions. This is model-relative, not reader-relative: two people disagreeing over whether a line is a no-op disagree about the default, and settle it by running the skill, not by debate.
|
|
194
|
+
|
|
195
|
+
_Avoid_: redundant instruction, restating the obvious, belaboring
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Pocock
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|