@ssheleg/agent-stack 0.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,90 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
+ Versioning: [SemVer](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.3.0] — 2026-08-12
8
+
9
+ ### Changed
10
+
11
+ - **The description now opens with `Use when …` and carries paired Russian triggers.**
12
+ That has been the family canon since `super-ux` v0.20.0; this repository was created
13
+ after it and never adopted it, so the skill did not match a request written in
14
+ Russian — and a skill that does not match is a skill that is not there. 923/1024
15
+ chars, inside the 970 working limit that v0.2.0 had already brought it under.
16
+
17
+ ## [0.2.0] — 2026-08-11
18
+
19
+ ### Changed
20
+
21
+ - **The body went 604 lines / 5361 tokens to 459 / 4146** — the caps are 500
22
+ and 5000, and it was the only skill in the family over both. Measured with
23
+ `cl100k`.
24
+
25
+ Sections 6 (provider routing) and 7 (memory layers) were carrying depth that
26
+ `references/llm-proxy-billing.md` and `references/patterns.md` already hold —
27
+ fallback chains and retry/backoff in the first, confidence management,
28
+ extraction heuristics, fuzzy deduplication and conflict resolution in the
29
+ second. The body keeps the shape of each (the four-layer table, the router's
30
+ contract) plus the traps, and points at the depth.
31
+
32
+ The traps stay inline because an agent cannot know to open a file about a
33
+ trap it does not know exists: a retry loop and a fallback chain **multiply**,
34
+ a health check that only runs on failure never recovers, model selection has
35
+ three levels and a silent precedence bug bills a cheap model at a premium
36
+ rate, and every memory layer competes for one context window — give layer 1 a
37
+ floor or old generalities crowd out what the user said a minute ago.
38
+
39
+ - `references/patterns.md` gains the `## Contents` list the canon requires of a
40
+ reference over 100 lines: a partial read is what agents actually do, and
41
+ without the list it returns an arbitrary slice.
42
+
43
+ - The description trimmed 975 → 937 chars, inside the 970 headroom, by dropping
44
+ two trigger phrases already covered by their neighbours.
45
+
46
+ ## [0.1.0] — 2026-08-06
47
+
48
+ First release. The skill is a port: it was written and used inside Cursor
49
+ against a production multi-agent system, and this repository is where it
50
+ becomes installable, versioned and checked.
51
+
52
+ ### Added
53
+
54
+ - **`agent-orchestrator` skill** (618 lines) — the orchestrator pattern with a
55
+ shared context object and a sub-agent protocol; a tool-calling loop with
56
+ in-loop trimming, wrap-up injection at ~70% of the window and a max-iteration
57
+ guard that still composes a partial answer; meta-tools that delegate rather
58
+ than execute; sub-agent retry split into retryable and fatal; a multi-stage
59
+ pipeline with complexity detection, human-in-the-loop checkpoints and resume;
60
+ multi-provider routing with fallback, exponential backoff and health checks;
61
+ a four-layer memory system (chat history, working memory, long-term learnings,
62
+ insights) with confidence lifecycles, fuzzy dedup, conflict resolution and
63
+ decay; context budget allocation; self-learning feedback loops.
64
+ - **`references/patterns.md`** (351 lines) — the data models and algorithms
65
+ behind the above: message and result protocols, pipeline models, the SQL
66
+ validation loop, context-window sizes and token estimation, learning
67
+ extraction heuristics, confidence management, the fuzzy-dedup and
68
+ conflict-resolution patterns, cross-resource transfer, and a suggestion engine
69
+ that costs no LLM calls.
70
+ - **`references/llm-proxy-billing.md`** (255 lines) — the wallet side of
71
+ reselling LLM access, generalized from an OpenRouter Management API
72
+ integration: tiered balances and the single boundary where markup applies,
73
+ two-phase commit against a provider API with compensating transactions,
74
+ transaction-scoped advisory locking, optimistic concurrency for reclaims,
75
+ spend-delta polling and the three cases it must distinguish, budget/loop/
76
+ auto-pause guardrails converging on one pause function with per-cause
77
+ timestamps, per-tenant key lifecycle and healing, the refund waterfall, and
78
+ model routing precedence.
79
+ - Structural validator (`test/validate.py`) enforcing one version across four
80
+ files, Agent Skills front-matter limits, and reference links in **both**
81
+ directions — the source this skill came from shipped a `reference.md` that
82
+ nothing referenced, and that is now a failing check.
83
+ - Installer CLI, `install.sh`, Cursor rule channel, plugin + marketplace
84
+ manifests, CI with negative self-tests.
85
+
86
+ ### Notes
87
+
88
+ The `references/patterns.md` file was `reference.md` in the source and was
89
+ renamed on the way in: it is loaded by name from `SKILL.md`, and the validator
90
+ now requires that link to resolve.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ssheleg
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.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # agent-stack
2
+
3
+ Production patterns for building AI agent orchestrators — and for billing the
4
+ LLM access they burn.
5
+
6
+ Part of the [ssheleg skill family](https://github.com/ssheleg/sshlg-skills).
7
+
8
+ ---
9
+
10
+ ## What is in here
11
+
12
+ One skill, `agent-orchestrator`, and two references it loads on demand.
13
+
14
+ **The orchestrator** (`SKILL.md`) — what the agent reads first:
15
+
16
+ - a shared context object and a sub-agent protocol with typed results
17
+ - a tool-calling loop that survives its own context pressure: in-loop trimming
18
+ at ~80% of the window, a wrap-up instruction at ~70%, a max-iteration guard
19
+ that still composes a partial answer instead of returning nothing
20
+ - meta-tools that **delegate to sub-agents** rather than execute directly
21
+ - sub-agent retry split into retryable and fatal, with validation between tries
22
+ - a multi-stage pipeline for complex work: complexity detection, checkpoints
23
+ where a human approves, and resume after they do
24
+ - multi-provider LLM routing with a fallback chain, per-provider exponential
25
+ backoff that respects `retry_after`, health checks and one error hierarchy
26
+ - a four-layer memory system — chat history, working memory, long-term
27
+ learnings, insights — each with its own lifetime, confidence lifecycle and
28
+ decay, plus conflict resolution when a new learning contradicts an old one
29
+ - context budget allocation by priority
30
+ - self-learning feedback loops
31
+
32
+ **`references/patterns.md`** — the data models and algorithms underneath:
33
+ message and result protocols, pipeline models, the SQL validation loop,
34
+ context-window sizes and token estimation, learning-extraction heuristics,
35
+ confidence management, fuzzy deduplication, conflict resolution, cross-resource
36
+ learning transfer, and a suggestion engine that costs no LLM calls.
37
+
38
+ **`references/llm-proxy-billing.md`** — for when the product resells LLM access:
39
+ tiered wallets and the single boundary where markup applies, two-phase commit
40
+ across a database and a provider API with compensating transactions,
41
+ transaction-scoped advisory locking, optimistic concurrency for reclaims,
42
+ spend-delta polling and the three cases it must tell apart, budget / loop /
43
+ auto-pause guardrails, per-tenant key lifecycle and healing, the refund
44
+ waterfall, and model-routing precedence.
45
+
46
+ ---
47
+
48
+ ## Install
49
+
50
+ **Claude Code plugin** (recommended):
51
+
52
+ ```bash
53
+ /plugin marketplace add ssheleg/agent-stack
54
+ /plugin install agent-stack@agent-stack
55
+ ```
56
+
57
+ **npm installer** — copies the skill into `~/.claude/skills/`:
58
+
59
+ ```bash
60
+ npx @ssheleg/agent-stack
61
+ ```
62
+
63
+ **Any of 70+ agents:**
64
+
65
+ ```bash
66
+ npx skills add ssheleg/agent-stack
67
+ ```
68
+
69
+ **Whole family at once:**
70
+
71
+ ```bash
72
+ npx --yes sshlg-skills@latest update
73
+ ```
74
+
75
+ Restart your agent afterwards — skills load at session start.
76
+
77
+ ---
78
+
79
+ ## When it triggers
80
+
81
+ Building an agent system, an orchestrator, an LLM-powered tool, a chatbot with
82
+ tool use, or an AI pipeline. Also when the work is the money side: metering
83
+ usage, per-tenant keys, spend tracking, budget limits, loop detection.
84
+
85
+ It does **not** trigger for a single LLM call in a script, or for prompt
86
+ wording — that is not an orchestrator, and pulling 1200 lines of doctrine for it
87
+ is how a skill teaches you to route around it.
88
+
89
+ ---
90
+
91
+ ## Verify
92
+
93
+ ```bash
94
+ python3 test/validate.py
95
+ ```
96
+
97
+ Checks one version across `package.json`, `plugin.json`, `marketplace.json` and
98
+ the top `CHANGELOG` entry; front matter inside the Agent Skills limits (over-long
99
+ front matter does not error — hosts truncate it silently, which is worse); and
100
+ that `SKILL.md` and `references/` agree in **both** directions, so neither a
101
+ dangling link nor a file nobody loads can ship.
102
+
103
+ ---
104
+
105
+ ## License
106
+
107
+ MIT © ssheleg
package/SECURITY.md ADDED
@@ -0,0 +1,63 @@
1
+ # Security
2
+
3
+ ## What this skill actually does on your machine
4
+
5
+ `agent-stack` is documentation plus one small Python script. Installed, it is:
6
+
7
+ | Component | Runtime behavior |
8
+ |---|---|
9
+ | `SKILL.md` + `references/*.md` | Text. Read by the agent, executes nothing. |
10
+ | `scripts/page_audit.py` | Runs only when you or the agent invokes it. Python **standard library only** — no dependencies, no install step. |
11
+ | `commands/`, `cursor/rules/` | Text read by the host agent. |
12
+ | `bin/agent-stack.js` (npm installer) | Copies the skill directory and the slash command into `~/.claude/`. No network, no post-install script. |
13
+
14
+ There is no telemetry, no analytics, no phone-home, and nothing writes outside
15
+ the paths above.
16
+
17
+ ## Network behavior of `page_audit.py`
18
+
19
+ - Plain `GET` requests, **http and https only** — any other scheme (`file://`,
20
+ `ftp://`, `gopher://`, …) is refused before a request is made, and a redirect
21
+ that leaves http(s) is refused too.
22
+ - Only to URLs **you** pass via `--url` / `--url-list`. In `--file` mode it makes
23
+ no requests at all, which is how the test suite runs.
24
+ - No cookies, no credentials, no auth headers; a plain User-Agent that identifies
25
+ the tool.
26
+ - Bounded: `--timeout` (default 20s) and `--max-bytes` (default 5 MB). A declared
27
+ content type that is not HTML/XHTML/XML is refused rather than parsed.
28
+ - Read-only: results go to stdout. The script never writes a file. The only files
29
+ it ever **reads** are the two you name yourself (`--file`, `--url-list`).
30
+
31
+ ## What the skill will not tell an agent to do
32
+
33
+ The audit procedure is explicitly **defensive**. Manipulative tactics —
34
+ cloaking, fabricated consensus networks, review manipulation, click-signal
35
+ spoofing, takedown abuse — appear only in `references/threats-and-defense.md`,
36
+ written as *detect and withstand*, and the skill's non-negotiables forbid
37
+ recommending them.
38
+
39
+ The procedure is also read-only by default: it will not submit forms, request
40
+ indexing, disavow links or change a live property without explicit approval in
41
+ the session.
42
+
43
+ ## Reporting a problem
44
+
45
+ Open an issue at <https://github.com/ssheleg/agent-stack/issues>. If it is
46
+ sensitive, say so in the issue without the details and a private channel will be
47
+ arranged.
48
+
49
+ ## Verifying for yourself
50
+
51
+ ```bash
52
+ git clone https://github.com/ssheleg/agent-stack && cd agent-stack
53
+ python3 test/validate.py # structure, version sync, references, links, anchors
54
+ python3 test/test_page_audit.py # auditor behavior, offline fixtures + scheme guard
55
+ grep -rnE "urlopen|build_opener|opener\.open|socket|subprocess|os\.system|\beval\(|\bexec\(|\bopen\(" \
56
+ plugins/agent-stack/skills/agent-stack/scripts/page_audit.py
57
+ ```
58
+
59
+ The last command prints the auditor's entire I/O surface — six lines: the
60
+ `urllib.request` import, one comment, the opener that carries the scheme guard,
61
+ the one `opener.open(...)` call, and the two `open()` calls that read the file
62
+ paths you pass on the command line. No `subprocess`, no `os.system`, no `eval`,
63
+ no `exec`, no raw sockets. Everything else in `plugins/` is markdown.
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * agent-stack installer CLI.
4
+ *
5
+ * Installs the agent-orchestrator skill into ~/.claude/skills/agent-orchestrator
6
+ * (same layout as install.sh). Idempotent: an existing install is skipped unless
7
+ * --force. Zero dependencies.
8
+ *
9
+ * For other agents (Cursor, Codex, 70+) use: npx skills add ssheleg/agent-stack
10
+ */
11
+ 'use strict';
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const os = require('os');
16
+
17
+ const ROOT = path.resolve(__dirname, '..');
18
+ const REPO = 'ssheleg/agent-stack';
19
+
20
+ function usage() {
21
+ console.log(`agent-stack installer
22
+
23
+ Usage:
24
+ npx @ssheleg/agent-stack [--force] install the agent-orchestrator skill
25
+ into ~/.claude (skip existing unless --force)
26
+ npx @ssheleg/agent-stack --help
27
+
28
+ Other install paths:
29
+ Claude Code plugin: /plugin marketplace add ${REPO}
30
+ /plugin install agent-stack@agent-stack
31
+ Any agent (70+): npx skills add ${REPO}`);
32
+ }
33
+
34
+ function copyDir(src, dest) {
35
+ fs.mkdirSync(dest, { recursive: true });
36
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
37
+ const s = path.join(src, entry.name);
38
+ const d = path.join(dest, entry.name);
39
+ if (entry.isDirectory()) copyDir(s, d);
40
+ else fs.copyFileSync(s, d);
41
+ }
42
+ }
43
+
44
+ function installOne(label, src, dest, isDir, force) {
45
+ if (fs.existsSync(dest) && !force) {
46
+ console.log(`skip: ${label} already installed at ${dest} (rerun with --force to overwrite)`);
47
+ return;
48
+ }
49
+ fs.rmSync(dest, { recursive: true, force: true });
50
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
51
+ if (isDir) copyDir(src, dest);
52
+ else fs.copyFileSync(src, dest);
53
+ console.log(`Installed ${label} -> ${dest}`);
54
+ }
55
+
56
+ function main(argv) {
57
+ const args = argv.slice(2);
58
+ if (args.includes('--help') || args.includes('-h')) {
59
+ usage();
60
+ return 0;
61
+ }
62
+ const force = args.includes('--force');
63
+ const unknown = args.filter((a) => a !== '--force');
64
+ if (unknown.length) {
65
+ console.error(`unknown argument(s): ${unknown.join(' ')}`);
66
+ usage();
67
+ return 2;
68
+ }
69
+
70
+ const skillSrc = path.join(ROOT, 'plugins/agent-stack/skills/agent-orchestrator');
71
+ if (!fs.existsSync(skillSrc)) {
72
+ console.error(`error: skill sources missing at ${skillSrc} — corrupted package?`);
73
+ return 1;
74
+ }
75
+
76
+ const home = os.homedir();
77
+ installOne(
78
+ 'agent-orchestrator skill',
79
+ skillSrc,
80
+ path.join(home, '.claude', 'skills', 'agent-orchestrator'),
81
+ true,
82
+ force
83
+ );
84
+ return 0;
85
+ }
86
+
87
+ process.exit(main(process.argv));
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@ssheleg/agent-stack",
3
+ "version": "0.3.0",
4
+ "description": "Production patterns for AI agent orchestrators — tool-calling loops, multi-stage pipelines with checkpoints, LLM provider routing with fallback, four-layer memory with confidence decay — plus the wallet side of reselling LLM access. This package is the installer CLI.",
5
+ "bin": {
6
+ "agent-stack": "bin/agent-stack.js"
7
+ },
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "plugins",
14
+ "README.md",
15
+ "LICENSE",
16
+ "CHANGELOG.md",
17
+ "SECURITY.md"
18
+ ],
19
+ "repository": "github:ssheleg/agent-stack",
20
+ "homepage": "https://github.com/ssheleg/agent-stack",
21
+ "license": "MIT",
22
+ "author": {
23
+ "name": "ssheleg",
24
+ "url": "https://x.com/sshlg93"
25
+ },
26
+ "engines": {
27
+ "node": ">=16"
28
+ },
29
+ "keywords": [
30
+ "agent",
31
+ "orchestrator",
32
+ "llm",
33
+ "tool-calling",
34
+ "multi-agent",
35
+ "openrouter",
36
+ "llm-billing",
37
+ "claude-code",
38
+ "cursor",
39
+ "skill"
40
+ ]
41
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "agent-stack",
3
+ "displayName": "Agent Stack",
4
+ "description": "Production patterns for AI agent orchestrators: tool-calling loops, multi-stage pipelines with checkpoints, LLM provider routing with fallback, four-layer memory with confidence decay — plus the wallet side of reselling LLM access.",
5
+ "version": "0.3.0",
6
+ "author": {
7
+ "name": "ssheleg",
8
+ "url": "https://x.com/sshlg93"
9
+ },
10
+ "homepage": "https://github.com/ssheleg/agent-stack",
11
+ "repository": "https://github.com/ssheleg/agent-stack",
12
+ "license": "MIT",
13
+ "keywords": [
14
+ "agent",
15
+ "orchestrator",
16
+ "llm",
17
+ "tool-calling",
18
+ "multi-agent",
19
+ "openrouter",
20
+ "llm-billing",
21
+ "claude-code",
22
+ "cursor"
23
+ ]
24
+ }