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
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,33 @@ jobs:
components: rustfmt
- run: cargo fmt --check

# The SDKs and the VS Code extension, against their fake incode/agent.
sdk-and-editor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python3 -m unittest discover sdk/python/tests
- run: npm ci && npm test
working-directory: sdk/typescript
- run: npm ci && npm run compile && npm test
working-directory: editors/vscode

test:
name: test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
# A whole run takes under 15 minutes; a test that hangs fails the job
# here instead of holding it for GitHub's 6-hour default.
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
# The Linux desktop backends (xcap, enigo's x11rb, AT-SPI over zbus)
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ Prices for `/cost`, the status line and `-t --output-format json` (`cost_usd`) a

`incode review` (and `/review` in a session) hands the model the change and
one job: report correctness bugs first, then security problems, then
simplifications, each cited as `path:line` — or say "No issues found."
simplifications, each cited as `path:line` — or say "No issues found." It
runs read-only: the agent may read the code and run nothing that writes.

```sh
incode review # the branch since it forked from origin's default branch, plus uncommitted and untracked work
Expand Down Expand Up @@ -1352,11 +1353,15 @@ The full list is in `docs/ROADMAP.md`.
## Development

```sh
cargo test # about 1,900 tests (1,878 library, 46 binary)
scripts/test-all.sh # everything CI runs, and the SDKs and editor extension
cargo test # about 2,100 tests (library and binary)
cargo clippy --all-targets -- -D warnings
cargo fmt
```

[TESTING.md](TESTING.md) lists every suite, the Windows check, the live tests
that are off by default and what is worth trying by hand.

The documents under `docs/` are the input the loop reads, not decoration:
`PRD.md` (what and why), `ARCHITECTURE.md` (the shape), `CONVENTIONS.md` (how
the code should read), `ASSUMPTIONS.md` (what was decided without asking),
Expand Down
84 changes: 84 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Testing incode locally

Everything CI runs, and the parts it cannot, from your own machine.

## One command

```sh
scripts/test-all.sh # every part this machine has the toolchain for
scripts/test-all.sh rust sbx # only some parts: rust sbx python ts vscode
QUICK=1 scripts/test-all.sh # the same without clippy (the slowest step)
```

A part whose toolchain (cargo, python3, npm) or folder is missing is skipped
and named in the summary; the exit code is non-zero when any part that ran
failed.

On Linux, building incode needs the desktop backends' libraries:

```sh
sudo apt-get install -y --no-install-recommends pkg-config clang libclang-dev \
libwayland-dev libpipewire-0.3-dev libxcb1-dev libxcb-randr0-dev \
libxcb-shm0-dev libdbus-1-dev libegl-dev libgbm-dev
```

The tests create git repositories and commit in them, so git needs a name and
an email (`git config --global user.name ...`, `user.email ...`).

## The parts

| Part | Commands | What it covers |
|---|---|---|
| rust | `cargo fmt --all -- --check` · `cargo clippy --all-targets -- -D warnings` · `cargo test --lib` · `cargo test --bins` | incode itself: about 2,100 library and 50 binary tests |
| rust | `cargo test --test sbx_engine` | Real shell commands run under `sandbox_engine = "sbx"`: a write outside the workspace refused (with an unconfined control), a planted git hook undone, `GIT_DIR` stripped. Linux; says it skipped elsewhere |
| sbx | `cargo clippy -p incord-sandbox --all-targets -- -D warnings` · `cargo test -p incord-sandbox` | The standalone sandbox: escape tests per OS, the MCP server, `.git` protection, WSL path translation |
| python | `python3 -m unittest discover sdk/python/tests` | The Python SDK, against a fake incode |
| ts | `cd sdk/typescript && npm install && npm test` | The TypeScript SDK, against the same fake |
| vscode | `cd editors/vscode && npm install && npm run compile && npm test` | The VS Code extension's ACP client, against a fake agent |

The SDK and extension suites also talk to the real binary when you point them
at one: `INCODE_BIN=$PWD/target/debug/incode` (build it first with
`cargo build`).

## Windows

From the incode folder, in PowerShell:

```powershell
powershell -ExecutionPolicy Bypass -File scripts\test-windows.ps1
```

It builds `sbx`, runs its Windows tests (writes outside the workspace, child
processes, the time, CPU and memory limits, killing `sbx`, the environment,
exit codes, the MCP server) and writes `sbx-windows-report.txt`. These need
real Windows: Wine cannot check Windows' own security. Nothing is installed
and nothing outside a temp folder is changed.

The whole Rust suite runs on Windows too (`cargo test --lib`, `cargo test --bins`).

## Live tests, off by default

`#[ignore]`d because they touch the real machine or need a service. Run one
with `cargo test --lib <name> -- --ignored --nocapture`.

| Test | Needs | What it does |
|---|---|---|
| `sandbox::windows::acl` `live_*` | Windows; `INCODE_SANDBOX_LIVE_DIR` (a scratch folder) and `INCODE_SANDBOX_LIVE_BIN` (a built `incode.exe`) | Grants, confines and restores real ACLs; sweeps a crashed session's grant |
| `desktop::thread` (moves the cursor) | A desktop session you are not using | Moves the real mouse and puts it back |
| `desktop::capture::tests::live::report_real_capture` | A display | Captures the real screen and prints the coordinate mapping |
| `desktop::win32`, `desktop::uia` reports | Windows | Print the display table and the focused window's accessibility tree |
| `toolbox::code_edits_tests::live_an_unseen_change_is_refused_by_the_engine` | `INCODE_LIVE_MEMORY_URL` (a throwaway Incord Memory engine) and `INCODE_LIVE_REPO` | Checks the engine refuses an edit to code it has not seen |

## By hand

Things the suites cannot judge, worth a minute in a real terminal and editor:

- `incode` in a terminal: the status line (`statusline_command`), `/vim`,
`/cost`, a notification after a long turn (`notify`), a custom command from
`.incode/commands/`, `/review`.
- `incode review` on a branch with a change; `incode mcp login <name>` against
a remote MCP server that needs a login; `incode plugin add` / `update`.
- `sandbox_engine = "sbx"` with `sandbox_allow_hosts`, then a command that
reaches an allowed host and one that does not.
- The VS Code extension (install the `.vsix` its README builds) and any ACP
editor (`incode --acp`).
3 changes: 2 additions & 1 deletion crates/sandbox/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ mod tests {
#[test]
fn the_documented_example_parses() {
let doc = include_str!("policy.rs")
.split("//! ```toml\n")
// Not `toml\n`: a Windows checkout has CRLF line endings.
.split("//! ```toml")
.nth(1)
.and_then(|rest| rest.split("//! ```").next())
.expect("the module docs carry an example");
Expand Down
8 changes: 7 additions & 1 deletion crates/sandbox/tests/protect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ fn a_planted_hook_and_config_are_put_back_after_the_run() {
repo.join("work.txt").exists(),
"ordinary work stays: {stderr}"
);
assert!(stderr.contains("protected path changed"), "{stderr}");
// Linux puts the paths back after the run and says so; macOS's profile
// refuses the writes outright, so there is nothing to put back.
if cfg!(target_os = "macos") {
assert!(stderr.contains("Operation not permitted"), "{stderr}");
} else {
assert!(stderr.contains("protected path changed"), "{stderr}");
}

// Opted out, the change stays.
Command::new(env!("CARGO_BIN_EXE_sbx"))
Expand Down
3 changes: 3 additions & 0 deletions editors/vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
out/
*.vsix
8 changes: 8 additions & 0 deletions editors/vscode/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
src/**
test/**
out/test/**
**/*.map
**/*.ts
tsconfig.json
.gitignore
node_modules/**
176 changes: 176 additions & 0 deletions editors/vscode/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
Loading
Loading