@agentage/cli 0.72.0 → 0.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -137
- package/dist/commands/extension/create-source.d.ts +1 -1
- package/dist/commands/extension/create-source.js +6 -2
- package/dist/commands/extension/release-changed.js +12 -6
- package/dist/commands/extension/release-ignore.d.ts +17 -0
- package/dist/commands/extension/release-ignore.js +73 -0
- package/dist/commands/extension/release-npm.d.ts +5 -0
- package/dist/commands/extension/release-npm.js +22 -0
- package/dist/commands/extension/release-plan.js +15 -8
- package/dist/commands/extension/release.js +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,171 +2,113 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
The agentage
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
The `agentage` command connects each machine you use to your agentage account and runs
|
|
6
|
+
extensions on it. It is also the tool to make and release your own extension. Use it from a
|
|
7
|
+
terminal, a server or CI. You need Node.js 22 or newer.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm
|
|
10
|
+
npm i -g @agentage/cli
|
|
11
|
+
agentage setup # sign in in your browser, then start the local daemon
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
The CLI stays **small**: sign-in, status, update and an extension manager. Sign-in uses OAuth 2.1
|
|
16
|
-
with PKCE: you type nothing into the terminal. Everything else, memory included, arrives as an
|
|
17
|
-
extension.
|
|
18
|
-
|
|
19
|
-
## Get started
|
|
20
|
-
|
|
21
|
-
`agentage setup` opens your browser for sign-in. Check the session with `agentage status`.
|
|
22
|
-
Installing and running extensions needs no sign-in. On a new machine, a signed-in `setup` installs
|
|
23
|
-
the extensions of your account's profile once; after that each machine keeps its own list.
|
|
24
|
-
|
|
25
|
-
### On a server or in CI (no browser)
|
|
26
|
-
|
|
27
|
-
`agentage setup --no-browser` prints the sign-in URL. Open it in a browser on this same machine,
|
|
28
|
-
because sign-in returns to `localhost`. On a server, use a personal access token from the
|
|
29
|
-
dashboard (**Settings**, then **API tokens**):
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
AGENTAGE_TOKEN=aga_... agentage status
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
More: [docs/reference.md](docs/reference.md#token-auth-ci-and-headless).
|
|
14
|
+
Status: before 1.0. Extensions run on the local daemon (`127.0.0.1:4243`) of each machine.
|
|
36
15
|
|
|
37
16
|
## Commands
|
|
38
17
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
| `agentage setup
|
|
44
|
-
| `agentage
|
|
45
|
-
| `agentage
|
|
46
|
-
| `agentage
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Extensions run with your privileges, in the daemon and in the CLI process, so install only ones
|
|
73
|
-
you trust. npm runs with `--ignore-scripts`. The account token leaves the environment before
|
|
74
|
-
extension code loads.
|
|
75
|
-
|
|
76
|
-
More: [docs/profiles.md](docs/profiles.md).
|
|
77
|
-
|
|
78
|
-
### Write and run your own extension
|
|
79
|
-
|
|
80
|
-
`create` needs git and network. `build --container`, `up --docker` and `release` also need
|
|
81
|
-
Docker and a committed tree; `release` needs the `gh` CLI.
|
|
18
|
+
Each command has `--help`. The full reference is [docs/reference.md](docs/reference.md).
|
|
19
|
+
|
|
20
|
+
| Command | What it does |
|
|
21
|
+
| ------------------------------ | ------------------------------------------------------------------------ |
|
|
22
|
+
| `agentage setup` | Sign in and connect this machine to your account; start the daemon |
|
|
23
|
+
| `agentage status` | Show the cli, account, endpoint, machine, profile and extension status |
|
|
24
|
+
| `agentage update` | Update `@agentage/cli` to the latest published version |
|
|
25
|
+
| `agentage daemon` | Start, show, stop or restart the local daemon that runs extensions |
|
|
26
|
+
| `extension install <name>` | Install an extension (`<id>`, `<id>@<version>` or a folder) and run it |
|
|
27
|
+
| `extension list` | Show each installed extension: id, version, source, state |
|
|
28
|
+
| `extension update [id]` | Move each market extension, or one, to its newest version |
|
|
29
|
+
| `extension disable <id>` | Stop an extension, keep its data |
|
|
30
|
+
| `extension enable <id>` | Run a disabled extension again |
|
|
31
|
+
| `extension configure <id> k=v` | Set settings (or `--secret` secrets) of an extension, no restart |
|
|
32
|
+
| `extension remove <id>` | Stop and remove an extension; its data stays unless `--purge` |
|
|
33
|
+
| `extension doctor` | Load every extension once and refresh its state: ok or failed |
|
|
34
|
+
| `extension create <id>` | Create `./extension-<id>` from the extension template |
|
|
35
|
+
| `extension check [dir]` | Check that an extension package conforms, as every build does first |
|
|
36
|
+
| `extension build` | Build the extension package; `--container` builds one image of all parts |
|
|
37
|
+
| `extension release` | Release an extension in CI; `--changed` releases each changed extension |
|
|
38
|
+
| `extension up` | Run the working copy on the daemon and reload each change |
|
|
39
|
+
| `extension down` | Stop what `extension up` started here |
|
|
40
|
+
| `extension token` | Print a token from the dev issuer that `extension up --docker` started |
|
|
41
|
+
|
|
42
|
+
`extension ...` means `agentage extension ...`. Add `--json` to most commands for one JSON object
|
|
43
|
+
on stdout: `{ success, data }` or `{ success: false, error }`. On a server with no browser, use a
|
|
44
|
+
personal access token: `AGENTAGE_TOKEN=aga_... agentage status`.
|
|
45
|
+
|
|
46
|
+
## Make your first extension
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
You need git and network. Run these in an empty folder:
|
|
82
51
|
|
|
83
52
|
```bash
|
|
84
|
-
agentage extension create
|
|
85
|
-
cd extension-
|
|
86
|
-
|
|
87
|
-
|
|
53
|
+
agentage extension create my-ext
|
|
54
|
+
cd extension-my-ext
|
|
55
|
+
npm ci
|
|
56
|
+
npm run verify
|
|
57
|
+
npx agentage extension check # PASS my-ext 0.1.2 conforms (6 rules)
|
|
58
|
+
git init -b master && git add -A && git commit -m "feat: my-ext extension"
|
|
88
59
|
```
|
|
89
60
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## Where things live
|
|
61
|
+
`create` copies the template from `agentage/kit:template` and writes your id into every file. In
|
|
62
|
+
the folder, use `npx agentage`: it runs the cli version that the folder pins. The guide of the new
|
|
63
|
+
folder is its own `README.md`. `check` may end with an `update available` line when the cli that
|
|
64
|
+
runs it is older than the newest on npm.
|
|
95
65
|
|
|
96
|
-
|
|
66
|
+
`create` builds the folder and gives it to the local daemon, so it runs at once. Add `--no-install`
|
|
67
|
+
to only create the files: CI and agents always do. Two more commands change the local daemon:
|
|
68
|
+
`npx agentage extension up` runs the folder there and reloads each change, and
|
|
69
|
+
`agentage extension install ./extension-my-ext` installs it there.
|
|
97
70
|
|
|
98
|
-
|
|
99
|
-
| ------------------------------- | ----------------------------------------------------- |
|
|
100
|
-
| `~/.agentage/auth.json` | your sign-in, owner-only |
|
|
101
|
-
| `~/.agentage/profile.json` | the profile: what this account wants |
|
|
102
|
-
| `~/.agentage/machine.json` | this machine's id, name, dev extensions and account |
|
|
103
|
-
| `~/.agentage/installation.json` | this machine's extension list, written by the daemon |
|
|
104
|
-
| `~/.agentage/daemon.json` | the running daemon: pid, port, host token; owner-only |
|
|
105
|
-
| `~/.agentage/extensions/` | installed extensions, one tree per id and version |
|
|
106
|
-
| `~/.agentage/state/` | the last run of each extension |
|
|
107
|
-
| `~/.agentage/commands.json` | cli 0.51's command holders; read, never written |
|
|
108
|
-
| `~/.agentage/secrets.json` | extension secrets, owner-only |
|
|
109
|
-
| `~/.agentage/data/<id>/` | what each extension keeps |
|
|
110
|
-
| `~/.agentage/logs/` | `daemon.log` and each extension's log |
|
|
71
|
+
## How an extension is released
|
|
111
72
|
|
|
112
|
-
|
|
73
|
+
Push the repo to GitHub. A release runs in CI in one of two modes:
|
|
113
74
|
|
|
114
|
-
|
|
115
|
-
|
|
75
|
+
- A repo with one or several extensions: each merge to master runs `agentage extension release --changed`. This is what a new repo from `create` does.
|
|
76
|
+
- A repo with one extension can instead release by a pushed tag `v<version>`: `agentage extension release`.
|
|
116
77
|
|
|
117
|
-
|
|
78
|
+
With `--changed`, a changed extension gets a date version
|
|
79
|
+
`YYYY.MDD.N` (for example `2026.1122.1`), the tag `<id>@<version>`, its images and its records on
|
|
80
|
+
the GitHub release. A change only in a root `*.md` file, `docs/` or `.github/` releases nothing.
|
|
81
|
+
A `.release-ignore` file adds more patterns. The new package is private: it goes to npm only when
|
|
82
|
+
you remove `"private": true`. The rule in full: [docs/reference.md](docs/reference.md#extension-release).
|
|
118
83
|
|
|
119
|
-
|
|
120
|
-
- Tokens land in `~/.agentage/auth.json` (owner-only) and refresh automatically.
|
|
121
|
-
- `status` checks the session against the account's introspection endpoint.
|
|
122
|
-
- The daemon is the only background process. It starts when a command needs it and runs until
|
|
123
|
-
`agentage daemon stop`. Nothing installs on a timer.
|
|
124
|
-
|
|
125
|
-
## Configuration
|
|
126
|
-
|
|
127
|
-
| Env | Default | Purpose |
|
|
128
|
-
| ------------------------- | --------------------- | -------------------------------------------------- |
|
|
129
|
-
| `AGENTAGE_SITE_FQDN` | `agentage.io` | Target host |
|
|
130
|
-
| `AGENTAGE_CONFIG_DIR` | `~/.agentage` | Config and credentials directory |
|
|
131
|
-
| `AGENTAGE_TOKEN` | - | Personal access token for CI and headless machines |
|
|
132
|
-
| `AGENTAGE_EXTENSIONS_DIR` | `<config>/extensions` | Where extensions are installed |
|
|
133
|
-
| `AGENTAGE_DAEMON_PORT` | `4243` | The daemon's port on 127.0.0.1 |
|
|
134
|
-
| `NO_COLOR` | - | Disable colored output |
|
|
135
|
-
|
|
136
|
-
## Develop
|
|
84
|
+
## How to work on this repo
|
|
137
85
|
|
|
138
86
|
```bash
|
|
139
87
|
npm ci
|
|
140
|
-
npm run verify
|
|
141
|
-
npm run build && npm run test:e2e -- --grep @offline
|
|
88
|
+
npm run verify # type-check, lint, format, test, build
|
|
89
|
+
npm run build && npm run test:e2e -- --grep @offline # e2e with a loopback npm registry
|
|
142
90
|
```
|
|
143
91
|
|
|
144
|
-
|
|
145
|
-
npm registry that serves `fixtures/`.
|
|
92
|
+
## How a change is released
|
|
146
93
|
|
|
147
|
-
|
|
94
|
+
A merge of a normal change releases nothing. The `chore(release): X.Y.Z` PR from
|
|
95
|
+
`prepare-release.yml` changes `package.json`; its merge runs `release.yml`, which publishes to npm
|
|
96
|
+
with OIDC trusted publishing and pushes the tag `vX.Y.Z`. Details: [docs/release.md](docs/release.md).
|
|
148
97
|
|
|
149
|
-
|
|
150
|
-
`chore(release): X.Y.Z` PR and arms auto-merge. On the merge, `release.yml` runs verify and the
|
|
151
|
-
agentage/e2e cli tier on the packed cli, then publishes to npm with OIDC trusted publishing and
|
|
152
|
-
provenance, and pushes the tag `vX.Y.Z`. It skips a version already on npm.
|
|
98
|
+
## For agents
|
|
153
99
|
|
|
154
|
-
-
|
|
155
|
-
|
|
156
|
-
-
|
|
157
|
-
- `release.yml` runs only the `@smoke` tests of the agentage/e2e cli tier on the candidate. The
|
|
158
|
-
lifecycle, execution and reload tests of agentage/e2e run on its own PRs against the published
|
|
159
|
-
cli.
|
|
160
|
-
- Before the release PR merges, check: the PR checks of the release commit are green, and the cli
|
|
161
|
-
project of agentage/e2e passes in full against the packed tarball of that commit
|
|
162
|
-
(`AGENTAGE_CLI_TARBALL=<tgz> npm run test:cli -- --retries=0`).
|
|
100
|
+
- Read [AGENTS.md](AGENTS.md) (the same file as `CLAUDE.md`): commands, layout and where each fact lives.
|
|
101
|
+
- Never run `setup`, `update`, `extension up` or `extension install` on a shared machine, and always add `--no-install` to `extension create`.
|
|
102
|
+
- Never publish to npm by hand: only `release.yml` publishes.
|
|
163
103
|
|
|
164
|
-
##
|
|
104
|
+
## Links
|
|
165
105
|
|
|
166
|
-
- [docs/reference.md](docs/reference.md): every flag, exit code
|
|
167
|
-
- [docs/profiles.md](docs/profiles.md): profiles, extension states, the plan and updates.
|
|
106
|
+
- [docs/reference.md](docs/reference.md): every flag, exit code, environment variable and file.
|
|
168
107
|
- [docs/extensions.md](docs/extensions.md): write, check and run your own extension.
|
|
108
|
+
- [docs/profiles.md](docs/profiles.md): profiles, extension states, the plan and updates.
|
|
109
|
+
- [agentage/kit](https://github.com/agentage/kit): the kit and the extension template.
|
|
110
|
+
- [agentage/examples](https://github.com/agentage/examples): the probe and fixture extensions.
|
|
169
111
|
|
|
170
112
|
## License
|
|
171
113
|
|
|
172
|
-
MIT
|
|
114
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const TEMPLATE = "agentage/
|
|
1
|
+
export declare const TEMPLATE = "agentage/kit:template";
|
|
2
2
|
export declare const OWN_TEMPLATES: string[];
|
|
3
3
|
export declare const fromRefusal: (from: string) => string;
|
|
4
4
|
export declare const repoRef: (from: string) => {
|
|
@@ -5,8 +5,12 @@ import { promisify } from 'node:util';
|
|
|
5
5
|
import { holdSignals } from '../../core/loader/dispose.js';
|
|
6
6
|
const run = promisify(execFile);
|
|
7
7
|
// The kit repo holds the template in its folder template/; the old repo held it at its root.
|
|
8
|
-
export const TEMPLATE = 'agentage/
|
|
9
|
-
export const OWN_TEMPLATES = [
|
|
8
|
+
export const TEMPLATE = 'agentage/kit:template';
|
|
9
|
+
export const OWN_TEMPLATES = [
|
|
10
|
+
TEMPLATE,
|
|
11
|
+
'agentage/platform:template',
|
|
12
|
+
'agentage/extension-template',
|
|
13
|
+
];
|
|
10
14
|
// owner/repo, then #branch and :folder, each optional: nothing that can pass for a flag or leave the repo.
|
|
11
15
|
const FROM = /^[\w.-]+\/[\w.-]+(?:#\w[\w./-]*)?(?::\w[\w.-]*(?:\/\w[\w.-]*)*)?$/;
|
|
12
16
|
export const fromRefusal = (from) => !FROM.test(from) || from.includes('..')
|
|
@@ -2,6 +2,7 @@ import { join } from 'node:path';
|
|
|
2
2
|
import { CliError } from '../../lib/json-output.js';
|
|
3
3
|
import { writeCiCopy } from './release-folders.js';
|
|
4
4
|
import { imagesOf, releaseGuard } from './release-guard.js';
|
|
5
|
+
import { amber, npmRefusal } from './release-npm.js';
|
|
5
6
|
import { fetchTags, git, planRelease } from './release-plan.js';
|
|
6
7
|
import { rowsOf, summary } from './release-summary.js';
|
|
7
8
|
import { attach, buildImages, fail, idChecks, npmVersion, onMaster, publish, PUBLISH_SECONDS, scoped, step, takeSecrets, } from './release-steps.js';
|
|
@@ -55,9 +56,11 @@ const prepare = async (s, p) => {
|
|
|
55
56
|
step(`version: ${p.id} is ${p.version} in this CI copy only`);
|
|
56
57
|
return pkg;
|
|
57
58
|
};
|
|
58
|
-
const npmStep = async (s, run, dir, pkg) => {
|
|
59
|
+
const npmStep = async (s, run, { dir, pkg, refusal }) => {
|
|
59
60
|
if (pkg['private'] === true)
|
|
60
61
|
return step('npm: private package, not published');
|
|
62
|
+
if (refusal)
|
|
63
|
+
return amber(`npm: ${refusal}`);
|
|
61
64
|
const push = scoped(s.deps.exec(dir, PUBLISH_SECONDS), s.secrets);
|
|
62
65
|
await publish(run, push, pkg, s.secrets['npm']?.['NPM_TOKEN']);
|
|
63
66
|
};
|
|
@@ -72,16 +75,19 @@ const imagesStep = async (s, p, run, pkg) => {
|
|
|
72
75
|
return built ? buildImages(dir, oneImage, s.deps.tool, committedBut(s)) : [];
|
|
73
76
|
};
|
|
74
77
|
// The record is the "released" marker: it goes up only after npm has the version.
|
|
75
|
-
const releaseOne = async (s, p) => {
|
|
78
|
+
const releaseOne = async (s, p, row) => {
|
|
76
79
|
const pkg = await prepare(s, p);
|
|
77
80
|
const dir = join(s.root, p.rel);
|
|
78
81
|
const run = scoped(s.deps.exec(dir, s.timeout), s.secrets);
|
|
79
82
|
const isPrivate = pkg['private'] === true;
|
|
80
|
-
|
|
83
|
+
const refusal = isPrivate ? undefined : await npmRefusal(run, s.repo, pkg);
|
|
84
|
+
if (refusal)
|
|
85
|
+
row.result = 'released, AMBER: npm skipped';
|
|
86
|
+
if (!isPrivate && !refusal)
|
|
81
87
|
await npmVersion(run);
|
|
82
88
|
await createTag(s, p.tag);
|
|
83
89
|
const records = await imagesStep(s, p, run, pkg);
|
|
84
|
-
await npmStep(s, run, dir, pkg);
|
|
90
|
+
await npmStep(s, run, { dir, pkg, refusal });
|
|
85
91
|
if (records.length > 0)
|
|
86
92
|
await attach(run, p.tag, s.repo, records, s.sha);
|
|
87
93
|
return {
|
|
@@ -89,7 +95,7 @@ const releaseOne = async (s, p) => {
|
|
|
89
95
|
version: p.version,
|
|
90
96
|
tag: p.tag,
|
|
91
97
|
built: records.length > 0,
|
|
92
|
-
published: !isPrivate,
|
|
98
|
+
published: !isPrivate && !refusal,
|
|
93
99
|
};
|
|
94
100
|
};
|
|
95
101
|
// Every changed extension is tried; its folder then no longer counts as a change for the next build.
|
|
@@ -98,7 +104,7 @@ const releaseAll = async (s, plan) => {
|
|
|
98
104
|
const rows = rowsOf(plan.refused, 'refused');
|
|
99
105
|
for (const p of plan.changed) {
|
|
100
106
|
const row = { id: p.id, version: p.version, result: 'released' };
|
|
101
|
-
await releaseOne(s, p).then((r) => void released.push(r), (err) => Object.assign(row, { result: 'failed', err }));
|
|
107
|
+
await releaseOne(s, p, row).then((r) => void released.push(r), (err) => Object.assign(row, { result: 'failed', err }));
|
|
102
108
|
s.written.push(p.rel);
|
|
103
109
|
rows.push(row);
|
|
104
110
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type Rule = {
|
|
2
|
+
re: RegExp;
|
|
3
|
+
keep: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const DEFAULT_IGNORE: string[];
|
|
6
|
+
export declare const ALWAYS_COUNTS: string[];
|
|
7
|
+
export declare const IGNORE_FILE = ".release-ignore";
|
|
8
|
+
export declare const globToRegex: (glob: string) => RegExp;
|
|
9
|
+
export declare const parseIgnore: (text: string) => Rule[];
|
|
10
|
+
export declare const isIgnored: (rules: Rule[], path: string) => boolean;
|
|
11
|
+
export type Sorted = {
|
|
12
|
+
counted: string[];
|
|
13
|
+
ignored: string[];
|
|
14
|
+
};
|
|
15
|
+
export declare const sortChanged: (root: string, rel: string, diff: string) => Promise<Sorted>;
|
|
16
|
+
export declare const firstFive: (files: string[]) => string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
// Anchored at the folder root: a deeper .md or docs/ may be served by the site or the image.
|
|
4
|
+
export const DEFAULT_IGNORE = [
|
|
5
|
+
'/*.md',
|
|
6
|
+
'/docs/**',
|
|
7
|
+
'/.github/**',
|
|
8
|
+
'/.repo-doctor.yml',
|
|
9
|
+
'/.gitignore',
|
|
10
|
+
'/.prettierrc*',
|
|
11
|
+
'/.editorconfig',
|
|
12
|
+
'/LICENSE',
|
|
13
|
+
];
|
|
14
|
+
// What goes into the image always counts, whatever an ignore pattern says.
|
|
15
|
+
export const ALWAYS_COUNTS = ['/package.json', '/package-lock.json', '/src/**', '/Dockerfile*'];
|
|
16
|
+
export const IGNORE_FILE = '.release-ignore';
|
|
17
|
+
const TOKENS = {
|
|
18
|
+
'**/': '(?:.*/)?',
|
|
19
|
+
'/**': '(?:/.*)?',
|
|
20
|
+
'**': '.*',
|
|
21
|
+
'*': '[^/]*',
|
|
22
|
+
'?': '[^/]',
|
|
23
|
+
};
|
|
24
|
+
// Gitignore-style: a pattern with a slash is anchored to the folder, one without matches any depth.
|
|
25
|
+
export const globToRegex = (glob) => {
|
|
26
|
+
const bare = glob.replace(/\/$/, '');
|
|
27
|
+
const anchored = bare.includes('/');
|
|
28
|
+
const body = bare
|
|
29
|
+
.replace(/^\//, '')
|
|
30
|
+
.replace(/\*\*\/|\/\*\*|\*\*|\*|\?|[.+^${}()|[\]\\]/g, (t) => TOKENS[t] ?? `\\${t}`);
|
|
31
|
+
return new RegExp(`^${anchored ? '' : '(?:.*/)?'}${body}$`);
|
|
32
|
+
};
|
|
33
|
+
const ruleOf = (line) => {
|
|
34
|
+
const keep = line.startsWith('!');
|
|
35
|
+
return { re: globToRegex(keep ? line.slice(1) : line), keep };
|
|
36
|
+
};
|
|
37
|
+
export const parseIgnore = (text) => text
|
|
38
|
+
.split('\n')
|
|
39
|
+
.map((l) => l.trim())
|
|
40
|
+
.filter((l) => l !== '' && !l.startsWith('#'))
|
|
41
|
+
.map(ruleOf);
|
|
42
|
+
// The path and each folder above it: `docs` also matches `docs/a.md`.
|
|
43
|
+
const candidates = (path) => path.split('/').map((_, i, parts) => parts.slice(0, i + 1).join('/'));
|
|
44
|
+
const hits = (re, path) => candidates(path).some((p) => re.test(p));
|
|
45
|
+
// The last matching rule wins, as in .gitignore.
|
|
46
|
+
export const isIgnored = (rules, path) => {
|
|
47
|
+
if (ALWAYS_COUNTS.some((g) => hits(globToRegex(g), path)))
|
|
48
|
+
return false;
|
|
49
|
+
let ignored = false;
|
|
50
|
+
for (const rule of rules)
|
|
51
|
+
if (hits(rule.re, path))
|
|
52
|
+
ignored = !rule.keep;
|
|
53
|
+
return ignored;
|
|
54
|
+
};
|
|
55
|
+
const rulesAt = async (dir) => {
|
|
56
|
+
const text = await readFile(join(dir, IGNORE_FILE), 'utf8').catch(() => '');
|
|
57
|
+
return parseIgnore([...DEFAULT_IGNORE, text].join('\n'));
|
|
58
|
+
};
|
|
59
|
+
// `diff` names files from the repo root; the patterns read them from the extension folder.
|
|
60
|
+
export const sortChanged = async (root, rel, diff) => {
|
|
61
|
+
const rules = await rulesAt(join(root, rel));
|
|
62
|
+
const prefix = rel === '.' ? '' : `${rel}/`;
|
|
63
|
+
const files = diff.split('\0').filter(Boolean);
|
|
64
|
+
const local = files.map((f) => f.slice(prefix.length));
|
|
65
|
+
return {
|
|
66
|
+
counted: local.filter((f) => !isIgnored(rules, f)),
|
|
67
|
+
ignored: local.filter((f) => isIgnored(rules, f)),
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export const firstFive = (files) => {
|
|
71
|
+
const more = files.length > 5 ? ` and ${files.length - 5} more` : '';
|
|
72
|
+
return `${files.slice(0, 5).join(', ')}${more}`;
|
|
73
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExtensionPackage } from '@agentage/extension/tool';
|
|
2
|
+
import type { Exec } from './release-guard.js';
|
|
3
|
+
export declare const OPT_IN = "agentagePublishFromPrivateRepo";
|
|
4
|
+
export declare const amber: (line: string) => void;
|
|
5
|
+
export declare const npmRefusal: (run: Exec, repo: string, pkg: ExtensionPackage) => Promise<string | undefined>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { fail, step } from './release-steps.js';
|
|
2
|
+
// The kit refuses unknown keys under `agentage`: the opt-in is a top-level package.json key.
|
|
3
|
+
export const OPT_IN = 'agentagePublishFromPrivateRepo';
|
|
4
|
+
export const amber = (line) => console.log(`AMBER ${line}`);
|
|
5
|
+
const optedIn = (pkg) => {
|
|
6
|
+
const config = pkg['publishConfig'];
|
|
7
|
+
return config?.access === 'public' && pkg[OPT_IN] === true;
|
|
8
|
+
};
|
|
9
|
+
const howTo = `set publishConfig.access to "public" and ${OPT_IN} to true to publish it`;
|
|
10
|
+
// Only a repo GitHub names public, or an opt-in, goes to npm; no clear answer stops the release.
|
|
11
|
+
export const npmRefusal = async (run, repo, pkg) => {
|
|
12
|
+
const read = await run('gh', ['api', `repos/${repo}`, '--jq', '.private']);
|
|
13
|
+
const answer = read.out.trim();
|
|
14
|
+
if (read.ok && answer === 'false')
|
|
15
|
+
return undefined;
|
|
16
|
+
if (!read.ok || answer !== 'true')
|
|
17
|
+
fail(`npm: cannot read whether ${repo} is private (${read.err || answer || 'no answer'})`);
|
|
18
|
+
if (!optedIn(pkg))
|
|
19
|
+
return `${repo} is a private repo: npm skipped; ${howTo}`;
|
|
20
|
+
step(`npm: ${repo} is private, ${pkg.name} opts in to public npm`);
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dateVersion, lastTag, newestTags, tagOf } from './release-date.js';
|
|
2
2
|
import { extensionFolders } from './release-folders.js';
|
|
3
|
+
import { firstFive, sortChanged } from './release-ignore.js';
|
|
3
4
|
import { RECORD } from './release-guard.js';
|
|
4
5
|
import { fail, step } from './release-steps.js';
|
|
5
6
|
// A build that always fails stops here: no new tag after this many tags in a row with no record.
|
|
@@ -42,15 +43,21 @@ const unrecorded = async (c, f, tags) => {
|
|
|
42
43
|
// From the last tag, not the push range: a run the concurrency group dropped is caught up here.
|
|
43
44
|
const whyOf = async (c, f, tags, last) => {
|
|
44
45
|
if (!last)
|
|
45
|
-
return `has no ${f.id}@* tag yet
|
|
46
|
+
return { why: `has no ${f.id}@* tag yet`, ignored: [] };
|
|
46
47
|
const missing = await unrecorded(c, f, tags);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// No renames: a move from src/ to docs/ names the src/ path; -z keeps odd names exact.
|
|
49
|
+
const args = ['diff', '--name-only', '-z', '--no-renames', last, c.sha, '--', f.rel];
|
|
50
|
+
const { counted, ignored } = await sortChanged(c.root, f.rel, await git(c.run, args, 'changed'));
|
|
51
|
+
if (counted.length > 0)
|
|
52
|
+
return { why: `differs from ${last} in ${firstFive(counted)}`, ignored };
|
|
50
53
|
// A release that failed after its tag: the next commit releases it with a new N.
|
|
51
54
|
if (missing[0] === last)
|
|
52
|
-
return `equals ${last}, which has no record
|
|
53
|
-
return
|
|
55
|
+
return { why: `equals ${last}, which has no record`, ignored };
|
|
56
|
+
return { ignored };
|
|
57
|
+
};
|
|
58
|
+
const sameAs = (f, last, ignored) => {
|
|
59
|
+
const only = ignored.length > 0 ? `; only ignored files changed: ${firstFive(ignored)}` : '';
|
|
60
|
+
step(`unchanged: ${f.id} (${f.rel}) is the same as ${String(last)}${only}`);
|
|
54
61
|
};
|
|
55
62
|
// A re-run of an old commit must not give older code a higher version than its last tag.
|
|
56
63
|
const inHistory = async (c, last, at) => {
|
|
@@ -72,10 +79,10 @@ const planOne = async (c, f) => {
|
|
|
72
79
|
return planned(f, last.slice(f.id.length + 1), `${last} is on this commit: resume it`);
|
|
73
80
|
if (last)
|
|
74
81
|
await inHistory(c, last, at);
|
|
75
|
-
const why = await whyOf(c, f, tags, last);
|
|
82
|
+
const { why, ignored } = await whyOf(c, f, tags, last);
|
|
76
83
|
if (why)
|
|
77
84
|
return planned(f, dateVersion(f.id, tags, c.now), why);
|
|
78
|
-
|
|
85
|
+
sameAs(f, last, ignored);
|
|
79
86
|
return undefined;
|
|
80
87
|
};
|
|
81
88
|
// One refused extension never stops the plan of the others.
|
|
@@ -52,9 +52,9 @@ export const runRelease = async (opts = {}, deps = defaultDeps) => {
|
|
|
52
52
|
export const addRelease = (group, release) => {
|
|
53
53
|
addJson(group
|
|
54
54
|
.command('release')
|
|
55
|
-
.description('Release an extension from its v* tag
|
|
55
|
+
.description('Release an extension in CI: from its v* tag, or with --changed each changed one on a merge')
|
|
56
56
|
.option('--dir <path>', 'the extension package folder (default: the current folder)')
|
|
57
57
|
.option('--timeout <seconds>', 'bound on each git, GitHub and npm check (default: 60; npm publish: 300)', Number)
|
|
58
|
-
.option('--changed', 'each extension (root or extensions/*) whose folder changed since its last <id>@* tag;
|
|
58
|
+
.option('--changed', 'each extension (root or extensions/*) whose folder changed since its last <id>@* tag; root docs/**, root *.md, .github/** and repo config (plus .release-ignore patterns) never trigger a release, package.json, the lock, src/** and Dockerfile* always do; a private repo skips npm unless the package opts in')
|
|
59
59
|
.option('--dry-run', 'with --changed: print what it would release, change nothing')).action(release);
|
|
60
60
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentage/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"description": "The agentage CLI - connect this machine to agentage from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"prepublishOnly": "npm run verify"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@agentage/apphost": "0.
|
|
58
|
-
"@agentage/extension": "0.
|
|
57
|
+
"@agentage/apphost": "0.5.0",
|
|
58
|
+
"@agentage/extension": "0.23.0",
|
|
59
59
|
"@electric-sql/pglite": "^0.5.16",
|
|
60
60
|
"@tailwindcss/postcss": "^4.3.5",
|
|
61
61
|
"chalk": "^6.0.0",
|