Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
plugin/scripts/te text eol=lf
plugin/scripts/te-hook text eol=lf
*.sh text eol=lf
*.cmd text eol=crlf
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,11 @@ agy plugin install dist/marketplace/tokeneconomizer
```

Start `agy` and send a prompt in a repository, then check with
`~/.tokeneconomizer/bin/te --host antigravity status`. `agy` has no plugin commands, so the
`~/.tokeneconomizer/bin/te --host antigravity status` (on Windows, `<plugin>\scripts\te.cmd --host antigravity status`, run in the repository; `<plugin>` is the folder above `scripts\te_bootstrap.py` in `%USERPROFILE%\.tokeneconomizer\bin\te.json`, which the first session writes). `agy` has no plugin commands, so the
plugin's commands run from a terminal. The plugin makes no model call through `agy`, which has no
option that runs a prompt with every tool off, so the paid proposer and the loop guard are off
and tool pruning is not available. macOS and Linux only:
on Windows `agy` runs hook commands through `cmd /c`, and this plugin's launcher is a POSIX shell
script. See [its limits](plugin/README.md#antigravity-cli).
and tool pruning is not available. Works across Windows, macOS, and Linux with native Windows batch launchers (`scripts\te-hook.cmd`, `scripts\te.cmd`). Tested on `agy` 1.5.1 and 1.5.2 on Windows 11, macOS, and Linux.
See [its limits](plugin/README.md#antigravity-cli).

**opencode** (experimental)

Expand Down Expand Up @@ -288,7 +287,7 @@ uninstalling, using Copilot with your own model key, and troubleshooting.
| Grok Build (experimental) | 1.0.70 | not tested |
| opencode (experimental) | 1.19.5 and 2.2.0 | not tested |
| Hermes Agent (experimental) | 0.22.5 | not tested |
| Antigravity CLI (experimental) | agy 1.5.1, macOS and Linux | not tested |
| Antigravity CLI (experimental) | agy 1.5.1 and 1.5.2, Windows 11, macOS and Linux | not tested |
| Factory Droid (experimental) | 0.233.0, macOS (below) | not tested |

The commands above were tested on the oldest and newest version in each range; newer versions
Expand All @@ -309,9 +308,10 @@ have not been tested yet.
- **Grok Build** support is experimental: it was verified on 1.0.70 only, against its documented
hook contract and live hook payloads. Learned facts reach the model with the session's first tool
call, and tool pruning is not available. See [its limits](plugin/README.md#grok-build).
- **Antigravity CLI** support is experimental: it was written against agy 1.5.1's hook contract
and transcript format, which are not a public interface, and only micro-skills' LLM-free facts
are supported: the plugin makes no model call through `agy`. See [its limits](plugin/README.md#antigravity-cli).
- **Antigravity CLI** support is experimental: it was tested against agy 1.5.1 and 1.5.2 on Windows 11,
macOS, and Linux. It was written against agy's hook contract and transcript format, which are not a
public interface, and only micro-skills' LLM-free facts are supported: the plugin makes no model call
through `agy`. See [its limits](plugin/README.md#antigravity-cli).
- **Hermes Agent** support is experimental: it was tested on 0.22.5 only, with a scripted local
model and one free real model, on the classic CLI and one-shot runs only. Micro-skills and a
redirect reaching a real model are verified there; the still-stuck notice reaching a person is
Expand Down Expand Up @@ -340,7 +340,7 @@ commands. They have the same names on every agent; only the way you type them di
| Cursor Agent | from a terminal: `~/.tokeneconomizer/bin/te --host cursor <command>` |
| Grok Build | from a terminal: `~/.tokeneconomizer/bin/te --host grok <command>` |
| Hermes Agent | from a terminal: `~/.tokeneconomizer/bin/te --host hermes <command>` |
| Antigravity CLI | from a terminal: `~/.tokeneconomizer/bin/te --host antigravity <command>` |
| Antigravity CLI | from a terminal: `~/.tokeneconomizer/bin/te --host antigravity <command>` (on Windows: `<plugin>\scripts\te.cmd --host antigravity <command>`, in the repository) |
| Factory Droid | `/tokeneconomizer-<command>` (e.g. `/tokeneconomizer-status`) |
| a terminal, in the repository | `~/.tokeneconomizer/bin/te <command>` |

Expand Down
22 changes: 12 additions & 10 deletions docs/PLUGIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -838,14 +838,15 @@ open-vocabulary. On a repository you do not trust, leave micro-skills off (the d
* **Hermes Agent** — experimental: micro-skills and the loop guard, on the classic CLI and one-shot
runs, verified with a scripted model and one free real model. Its limits are listed in
`plugin/README.md`.
* **Antigravity CLI (`agy`, experimental)** — micro-skills' LLM-free facts, written against
agy 1.5.1 and its own installed hook documentation; tool pruning is not implemented. The
plugin makes no model call through `agy`, which has no option that runs a prompt with every tool
off (`sidecall.NO_SIDE_CALLS`), so the paid proposer and the loop guard's judge never run. What
was captured live: hooks come from a `hooks.json` at the plugin root, run through `sh -c` in
that directory, with camelCase payloads that name no event (the hook file's command does,
`--event`) and leave out a zero (`invocationNum` 0, the first model call of a prompt). A
`PreToolUse` hook that prints `{}` makes agy deny the tool, so none is registered;
* **Antigravity CLI (`agy`, experimental)** — micro-skills' LLM-free facts, tested against
`agy` 1.5.1 and 1.5.2 on Windows 11, macOS, and Linux, using its installed hook documentation;
tool pruning is not implemented. The plugin makes no model call through `agy`, which has no
option that runs a prompt with every tool off (`sidecall.NO_SIDE_CALLS`), so the paid proposer
and the loop guard's judge never run. What was captured live: hooks come from a `hooks.json` at
the plugin root, invoking `./scripts/te-hook` on macOS/Linux and native batch launcher
`scripts\te-hook.cmd` on Windows, with camelCase payloads that name no event (the hook file's
command does, `--event`) and leave out a zero (`invocationNum` 0, the first model call of a
prompt). A `PreToolUse` hook that prints `{}` makes agy deny the tool, so none is registered;
`PostToolUse` carries no tool result and a matcher `"*"` never matches, so the results are read
from the conversation's `transcript_full.jsonl` at the next `PreInvocation` and at `Stop`, where
every result of the previous model call is already written (`trace/antigravity.py`). There is no
Expand All @@ -855,8 +856,9 @@ open-vocabulary. On a repository you do not trust, leave micro-skills off (the d
`SessionStart`, an `ephemeralMessage` (dropped after the turn) at `PreInvocation`. Calls a subagent
makes are not in the transcript and are not seen. Transcript token fields are absent from older
agy versions (unknown, not zero), and the transcript names no model, so session cost is priced
on the ledger's labelled fallback. macOS and Linux only: agy runs hook commands through
`cmd /c` on Windows, and the launcher is a POSIX shell script.
on the ledger's labelled fallback. Works across Windows, macOS, and Linux (tested on `agy` 1.5.1
and 1.5.2 on Windows 11, macOS, and Linux; on Windows, terminal commands run through the plugin's
`scripts\te.cmd`, in the repository).
* **Factory Droid (experimental)** — micro-skills, the loop guard and session cost, on 0.233.0
(macOS). No tool pruning: the TUI has no persistent per-tool setting (Factory issue #65). Side
calls are off until `droid_sidecall` is on; see `docs/DROID.md`.
Expand Down
11 changes: 6 additions & 5 deletions plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,7 @@ log a warning for the empty section of a session with no facts.

## Antigravity CLI

Experimental: **micro-skills' LLM-free facts**, written against `agy` 1.5.1 on macOS and Linux
(agy runs hook commands through `cmd /c` on Windows, and the launcher is a POSIX shell script).
Experimental: **micro-skills' LLM-free facts**, tested against `agy` 1.5.1 and 1.5.2 on Windows 11, macOS and Linux.

**1. Install.** Build the self-contained plugin, which copies the package into it, and install the
directory:
Expand All @@ -563,8 +562,10 @@ from `hooks.json` at the plugin root; the `hooks/hooks.json` beside it is Claude
validator says it is never loaded.

**2. Check it.** Run a session, then `~/.tokeneconomizer/bin/te --host antigravity status` in the
repository. agy plugins load no slash commands, so every command runs from a terminal. Micro-skills
is off by default: `te --host antigravity config set microskills=envfacts`.
repository (on Windows, `<plugin>\scripts\te.cmd --host antigravity status` in the repository;
`<plugin>` is the folder above `scripts\te_bootstrap.py` in `%USERPROFILE%\.tokeneconomizer\bin\te.json`, which the first session writes).
agy plugins load no slash commands, so every command runs from a terminal. Micro-skills
is off by default: `te --host antigravity config set microskills=envfacts` (on Windows: `<plugin>\scripts\te.cmd --host antigravity config set microskills=envfacts`).

**How it works, and what it does not do.**

Expand Down Expand Up @@ -711,7 +712,7 @@ How to run them:
| opencode | none (run from a terminal) | `~/.tokeneconomizer/bin/te --host opencode <command>` |
| Grok Build | none (run from a terminal) | `~/.tokeneconomizer/bin/te --host grok <command>` |
| Hermes Agent | none (run from a terminal) | `~/.tokeneconomizer/bin/te --host hermes <command>` |
| Antigravity CLI | none (run from a terminal) | `~/.tokeneconomizer/bin/te --host antigravity <command>` |
| Antigravity CLI | none (run from a terminal) | `~/.tokeneconomizer/bin/te --host antigravity <command>` (on Windows: `<plugin>\scripts\te.cmd --host antigravity <command>`, in the repository) |
| Factory Droid | `/tokeneconomizer-<command>` | `~/.tokeneconomizer/bin/te --host droid <command>` |

`doctor`, `history` and `repomap` run from a terminal (or as `/te …` on Pi); there is no slash command or
Expand Down
6 changes: 3 additions & 3 deletions plugin/hooks.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"tokeneconomizer": {
"SessionStart": [
{ "type": "command", "command": "./scripts/te-hook --host antigravity --event SessionStart", "timeout": 15 }
{ "type": "command", "command": "./scripts/te-hook --host antigravity --event SessionStart || scripts\\te-hook.cmd --host antigravity --event SessionStart", "timeout": 15 }
],
"PreInvocation": [
{ "type": "command", "command": "./scripts/te-hook --host antigravity --event PreInvocation", "timeout": 10 }
{ "type": "command", "command": "./scripts/te-hook --host antigravity --event PreInvocation || scripts\\te-hook.cmd --host antigravity --event PreInvocation", "timeout": 10 }
],
"Stop": [
{ "type": "command", "command": "./scripts/te-hook --host antigravity --event Stop", "timeout": 10 }
{ "type": "command", "command": "./scripts/te-hook --host antigravity --event Stop || scripts\\te-hook.cmd --host antigravity --event Stop", "timeout": 10 }
]
}
}
82 changes: 82 additions & 0 deletions plugin/scripts/te-hook.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
@echo off
setlocal EnableDelayedExpansion
set "DIR=%~dp0"
set "PYTHONUTF8=1"

:: 1. TE_PYTHON is the person's own choice: it runs as named when it is there, as a file or as
:: a command on PATH. One that is not there is passed over for the probes below, as the sh
:: launchers do, so a stale setting cannot keep the hook from answering. The name is read with
:: delayed expansion and run in quotes: a path with spaces or parentheses
:: ("C:\Program Files (x86)\...") stays one word and cannot end an `if` block early.
if not defined TE_PYTHON goto :probe
set "TE_PY=%TE_PYTHON:"=%"
if exist "!TE_PY!" (
set "RUN_PY="!TE_PY!""
goto :run_hook
)
where /q "!TE_PY!" >nul 2>&1
if !ERRORLEVEL! equ 0 (
set "RUN_PY="!TE_PY!""
goto :run_hook
)

:probe

:: Probe script: exits 0 if >= 3.10, exits 1 if older
set "PROBE=import sys; sys.exit(sys.version_info < (3, 10))"
set "OLD_PY="

:: 2. Probe py.exe (-3 launcher)
where py.exe >nul 2>&1
if !ERRORLEVEL! equ 0 (
py -3 -E -S -c "%PROBE%" >nul 2>&1
if !ERRORLEVEL! equ 0 (
set "RUN_PY=py -3"
goto :run_hook
) else if !ERRORLEVEL! equ 1 (
if not defined OLD_PY set "OLD_PY=py -3"
)
)

:: 3. Probe python.exe on PATH, skipping WindowsApps store alias
for /f "tokens=*" %%i in ('where python.exe 2^>nul') do (
echo %%~fi | findstr /i /c:"WindowsApps" >nul
if errorlevel 1 (
"%%~fi" -E -S -c "%PROBE%" >nul 2>&1
if !ERRORLEVEL! equ 0 (
set "RUN_PY="%%~fi""
goto :run_hook
) else if !ERRORLEVEL! equ 1 (
if not defined OLD_PY set "OLD_PY="%%~fi""
)
)
)

:: 4. Probe python3.exe on PATH, skipping WindowsApps store alias
for /f "tokens=*" %%i in ('where python3.exe 2^>nul') do (
echo %%~fi | findstr /i /c:"WindowsApps" >nul
if errorlevel 1 (
"%%~fi" -E -S -c "%PROBE%" >nul 2>&1
if !ERRORLEVEL! equ 0 (
set "RUN_PY="%%~fi""
goto :run_hook
) else if !ERRORLEVEL! equ 1 (
if not defined OLD_PY set "OLD_PY="%%~fi""
)
)
)

:: 5. If only older Python was found, hand off to it so bootstrap fails open
if defined OLD_PY (
set "RUN_PY=%OLD_PY%"
goto :run_hook
)

:: 6. Fail open: drain stdin and output empty JSON
for /f "tokens=*" %%a in ('more 2^>nul') do rem
echo {}
exit /b 0

:run_hook
%RUN_PY% "%DIR%te_bootstrap.py" hook %*
exit /b !ERRORLEVEL!
80 changes: 80 additions & 0 deletions plugin/scripts/te.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@echo off
setlocal EnableDelayedExpansion
set "DIR=%~dp0"
set "PYTHONUTF8=1"

:: 1. TE_PYTHON is the person's own choice: it runs as named when it is there, as a file or as
:: a command on PATH. One that is not there is passed over for the probes below, as the sh
:: launchers do, so a stale setting cannot keep the hook from answering. The name is read with
:: delayed expansion and run in quotes: a path with spaces or parentheses
:: ("C:\Program Files (x86)\...") stays one word and cannot end an `if` block early.
if not defined TE_PYTHON goto :probe
set "TE_PY=%TE_PYTHON:"=%"
if exist "!TE_PY!" (
set "RUN_PY="!TE_PY!""
goto :run_cli
)
where /q "!TE_PY!" >nul 2>&1
if !ERRORLEVEL! equ 0 (
set "RUN_PY="!TE_PY!""
goto :run_cli
)

:probe

:: Probe script: exits 0 if >= 3.10, exits 1 if older
set "PROBE=import sys; sys.exit(sys.version_info < (3, 10))"
set "OLD_PY="

:: 2. Probe py.exe (-3 launcher)
where py.exe >nul 2>&1
if !ERRORLEVEL! equ 0 (
py -3 -E -S -c "%PROBE%" >nul 2>&1
if !ERRORLEVEL! equ 0 (
set "RUN_PY=py -3"
goto :run_cli
) else if !ERRORLEVEL! equ 1 (
if not defined OLD_PY set "OLD_PY=py -3"
)
)

:: 3. Probe python.exe on PATH, skipping WindowsApps store alias
for /f "tokens=*" %%i in ('where python.exe 2^>nul') do (
echo %%~fi | findstr /i /c:"WindowsApps" >nul
if errorlevel 1 (
"%%~fi" -E -S -c "%PROBE%" >nul 2>&1
if !ERRORLEVEL! equ 0 (
set "RUN_PY="%%~fi""
goto :run_cli
) else if !ERRORLEVEL! equ 1 (
if not defined OLD_PY set "OLD_PY="%%~fi""
)
)
)

:: 4. Probe python3.exe on PATH, skipping WindowsApps store alias
for /f "tokens=*" %%i in ('where python3.exe 2^>nul') do (
echo %%~fi | findstr /i /c:"WindowsApps" >nul
if errorlevel 1 (
"%%~fi" -E -S -c "%PROBE%" >nul 2>&1
if !ERRORLEVEL! equ 0 (
set "RUN_PY="%%~fi""
goto :run_cli
) else if !ERRORLEVEL! equ 1 (
if not defined OLD_PY set "OLD_PY="%%~fi""
)
)
)

:: 5. If only older Python was found, hand off to it so bootstrap reports requirements
if defined OLD_PY (
set "RUN_PY=%OLD_PY%"
goto :run_cli
)

echo te: no python3 on PATH (set TE_PYTHON) >&2
exit /b 1

:run_cli
%RUN_PY% "%DIR%te_bootstrap.py" cli %*
exit /b !ERRORLEVEL!
Loading
Loading