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
12 changes: 9 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ jobs:
run: |
cmake --preset debug
cmake --build --preset debug
cmake --build --preset debug --target pony-doc-tests pony-lint-tests pony-lsp-tests pony-dep-tests
cmake --build --preset debug --target pony-doc-tests pony-lint-tests pony-lsp-tests pony-dep-tests pony-agent-server-tests
- name: Test pony-doc
run: ctest --preset debug -R pony-doc-tests
- name: Test pony-lint
Expand All @@ -386,6 +386,8 @@ jobs:
run: ctest --preset debug -R pony-lsp-tests
- name: Test pony-dep
run: ctest --preset debug -R pony-dep-tests
- name: Test pony-agent-server
run: ctest --preset debug -R pony-agent-server-tests
- name: Lint tools
run: cd build/debug && PONYPATH=../../tools/lib/ponylang/pony_compiler ./pony-lint ../../tools/
- name: Lint examples
Expand Down Expand Up @@ -418,7 +420,7 @@ jobs:
run: |
cmake --preset armv8-debug
cmake --build --preset armv8-debug
cmake --build --preset armv8-debug --target pony-doc-tests pony-lint-tests pony-lsp-tests pony-dep-tests
cmake --build --preset armv8-debug --target pony-doc-tests pony-lint-tests pony-lsp-tests pony-dep-tests pony-agent-server-tests
- name: Test pony-doc
run: ctest --preset armv8-debug -R pony-doc-tests
- name: Test pony-lint
Expand All @@ -427,6 +429,8 @@ jobs:
run: ctest --preset armv8-debug -R pony-lsp-tests
- name: Test pony-dep
run: ctest --preset armv8-debug -R pony-dep-tests
- name: Test pony-agent-server
run: ctest --preset armv8-debug -R pony-agent-server-tests

tools-windows:
needs: [changes, maybe-build-windows]
Expand Down Expand Up @@ -459,7 +463,7 @@ jobs:
run: |
cmake --preset windows-x86-64
cmake --build --preset windows-x86-64-debug
cmake --build --preset windows-x86-64-debug --target pony-doc-tests pony-lint-tests pony-lsp-tests pony-dep-tests
cmake --build --preset windows-x86-64-debug --target pony-doc-tests pony-lint-tests pony-lsp-tests pony-dep-tests pony-agent-server-tests
- name: Test pony-doc
run: ctest --preset windows-x86-64-debug -R pony-doc-tests
- name: Test pony-lint
Expand All @@ -468,6 +472,8 @@ jobs:
run: ctest --preset windows-x86-64-debug -R pony-lsp-tests
- name: Test pony-dep
run: ctest --preset windows-x86-64-debug -R pony-dep-tests
- name: Test pony-agent-server
run: ctest --preset windows-x86-64-debug -R pony-agent-server-tests

# ----- ssl-backends suite -----

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tools/pony-lsp/version.pony
tools/pony-lint/version.pony
tools/pony-doc/version.pony
tools/pony-dep/version.pony
tools/pony-agent-server/version.pony

# Python bytecode
__pycache__/
Expand Down
11 changes: 11 additions & 0 deletions .release-notes/add-pony-agent-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Add pony-agent-server

A new experimental tool for AI coding agents that need Pony type information while editing code. It compiles a package and answers queries about types, definitions, capabilities, and structure. The query interface is experimental and subject to change.

Start the server on a package directory:

```bash
pony-agent-server /path/to/my-project
```

Supported queries: `inspect`, `scope`, `exports`, `type_api`, `check`, `implementors`, `errors`, `reload`, and `status`. The server reads one JSON query per line from stdin and writes one JSON response per line to stdout.
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The output goes in `build/debug`. Use `--preset release` for a release build. Th
Tests are registered with ctest and grouped by label. Two labels matter:

- **`ci-core`** — built by a normal `cmake --build --preset debug`. The C/C++ compiler tests (`libponyc.tests`), the runtime tests (`libponyrt.tests`), the stdlib suite, full-program integration tests, and grammar validation.
- **`tools`** — **not** built by a normal `cmake --build --preset debug`. The self-hosted tool test suites: pony-compiler, pony-lsp, pony-lint, pony-doc, and pony-dep.
- **`tools`** — **not** built by a normal `cmake --build --preset debug`. The self-hosted tool test suites: pony-compiler, pony-lsp, pony-lint, pony-doc, pony-dep, and pony-agent-server.

### Core tests (ci-core)

Expand Down Expand Up @@ -87,6 +87,7 @@ Tool test binaries must be built explicitly before running. Build one target, th
- `cmake --build --preset debug --target pony-lint-tests && ctest --preset debug -R pony-lint-tests`
- `cmake --build --preset debug --target pony-doc-tests && ctest --preset debug -R pony-doc-tests`
- `cmake --build --preset debug --target pony-dep-tests && ctest --preset debug -R pony-dep-tests`
- `cmake --build --preset debug --target pony-agent-server-tests && ctest --preset debug -R pony-agent-server-tests`

Build all tool test binaries at once with `cmake --build --preset debug --target tool-tests`, then run them with `ctest --preset debug -L tools`.

Expand All @@ -100,7 +101,7 @@ Run the `pony-lint` binary (built by a normal `cmake --build --preset debug`) ag
cd build/debug && PONYPATH=../../tools/lib/ponylang/pony_compiler ./pony-lint ../../tools/pony-lint/
```

The same works for `../../tools/pony-lsp/`, `../../tools/pony-doc/`, and `../../tools/pony-dep/`.
The same works for `../../tools/pony-lsp/`, `../../tools/pony-doc/`, `../../tools/pony-dep/`, and `../../tools/pony-agent-server/`.

## Opening PRs

Expand Down
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ else()
add_subdirectory(tools/pony-lint)
add_subdirectory(tools/pony-doc)
add_subdirectory(tools/pony-dep)
add_subdirectory(tools/pony-agent-server)

# Test binaries compiled with the just-built ponyc. Built on demand, NOT under
# ALL: each runs ponyc to compile builtin and the stdlib packages, so building
Expand Down Expand Up @@ -897,12 +898,18 @@ else()
PATHS ${CMAKE_SOURCE_DIR}/tools/lib/ponylang/pony_compiler ${PONY_SSL_LIB_DIR}
WATCH ${CMAKE_SOURCE_DIR}/tools/pony-dep)

add_pony_binary(pony-agent-server-tests
NAME pony-agent-server-tests
SOURCE ${CMAKE_SOURCE_DIR}/tools/pony-agent-server/test
PATHS ${CMAKE_SOURCE_DIR}/tools/lib/ponylang/pony_compiler
WATCH ${CMAKE_SOURCE_DIR}/tools/pony-agent-server)

# On-demand aggregate: build every self-hosted tool test in one target. Run
# `cmake --build <dir> --target tool-tests` before `ctest -L tools`.
add_custom_target(tool-tests)
add_dependencies(tool-tests
pony-compiler-tests pony-doc-tests pony-lint-tests pony-lsp-tests
pony-dep-tests)
pony-dep-tests pony-agent-server-tests)

# ctest registration. Every test binary builds under ALL, so ctest only runs
# them. Labels group the suites: `ci-core` is the core CI suite (the old
Expand Down Expand Up @@ -944,6 +951,9 @@ else()
add_test(NAME pony-dep-tests
COMMAND ${PONY_OUTPUT_DIR}/pony-dep-tests${CMAKE_EXECUTABLE_SUFFIX} --sequential
WORKING_DIRECTORY ${PONY_OUTPUT_DIR})
add_test(NAME pony-agent-server-tests
COMMAND ${PONY_OUTPUT_DIR}/pony-agent-server-tests${CMAKE_EXECUTABLE_SUFFIX} --sequential
WORKING_DIRECTORY ${PONY_OUTPUT_DIR})
set_tests_properties(pony-lint-tests PROPERTIES
ENVIRONMENT "PONYPATH=${CMAKE_SOURCE_DIR}/packages;PONYTEST_DB_DIR=${CMAKE_SOURCE_DIR}/.ponytest/pony-lint-tests")
set_tests_properties(pony-doc-tests PROPERTIES
Expand All @@ -952,6 +962,8 @@ else()
ENVIRONMENT "PONYPATH=${CMAKE_SOURCE_DIR}/packages;PONYTEST_DB_DIR=${CMAKE_SOURCE_DIR}/.ponytest/pony-dep-tests")
set_tests_properties(pony-lsp-tests PROPERTIES
ENVIRONMENT "PONYTEST_DB_DIR=${CMAKE_SOURCE_DIR}/.ponytest/pony-lsp-tests")
set_tests_properties(pony-agent-server-tests PROPERTIES
ENVIRONMENT "PONYPATH=${CMAKE_SOURCE_DIR}/packages;PONYTEST_DB_DIR=${CMAKE_SOURCE_DIR}/.ponytest/pony-agent-server-tests")
add_test(NAME pony-compiler-tests
COMMAND ${PONY_OUTPUT_DIR}/pony-compiler-tests${CMAKE_EXECUTABLE_SUFFIX} --sequential
WORKING_DIRECTORY ${PONY_OUTPUT_DIR})
Expand All @@ -967,7 +979,7 @@ else()
ENVIRONMENT "PONYPATH=${CMAKE_SOURCE_DIR}/tools/lib/ponylang/pony_compiler:${CMAKE_SOURCE_DIR}/packages;PONYTEST_DB_DIR=${CMAKE_SOURCE_DIR}/.ponytest/pony-compiler-tests")
endif()
set_tests_properties(pony-doc-tests pony-lsp-tests pony-lint-tests pony-compiler-tests
pony-dep-tests PROPERTIES LABELS tools)
pony-dep-tests pony-agent-server-tests PROPERTIES LABELS tools)

# Compile-then-run ci-core tests. Each compiles Pony sources with the freshly
# built ponyc and then runs (or diffs) the result, so they depend on ponyc
Expand Down Expand Up @@ -1045,6 +1057,7 @@ else()
${PONY_OUTPUT_DIR}/pony-lint${CMAKE_EXECUTABLE_SUFFIX}
${PONY_OUTPUT_DIR}/pony-doc${CMAKE_EXECUTABLE_SUFFIX}
${PONY_OUTPUT_DIR}/pony-dep${CMAKE_EXECUTABLE_SUFFIX}
${PONY_OUTPUT_DIR}/pony-agent-server${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION ${PONY_VERSIONED_DIR}/bin)

# Runtime + compiler static libs, into the lib dir ponyc searches at run time
Expand Down Expand Up @@ -1138,7 +1151,7 @@ else()
endif()
endforeach()
file(MAKE_DIRECTORY \"\${_prefix}/bin\" \"\${_prefix}/lib\")
foreach(_tool ponyc pony-lsp pony-lint pony-doc pony-dep)
foreach(_tool ponyc pony-lsp pony-lint pony-doc pony-dep pony-agent-server)
set(_t \"\${_prefix}/${PONY_VERSIONED_DIR}/bin/\${_tool}\")
if(EXISTS \"\${_t}\")
file(CREATE_LINK \"\${_t}\" \"\${_prefix}/bin/\${_tool}\" SYMBOLIC)
Expand All @@ -1152,7 +1165,7 @@ else()
endforeach()
")
elseif(PONY_INSTALL_SYMLINKS AND WIN32)
foreach(_tool ponyc pony-lsp pony-lint pony-doc pony-dep)
foreach(_tool ponyc pony-lsp pony-lint pony-doc pony-dep pony-agent-server)
install(PROGRAMS $<TARGET_FILE:ponyc-shim>
DESTINATION bin RENAME ${_tool}.exe)
endforeach()
Expand Down
1 change: 1 addition & 0 deletions src/libponyc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ add_library(libponyc STATIC
type/sanitise.c
type/subtype.c
type/subtype_cache.c
type/subtype_ffi.c
type/type_assume.c
type/typealias.c
type/typeparam.c
Expand Down
22 changes: 22 additions & 0 deletions src/libponyc/type/subtype_ffi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "subtype_ffi.h"
#include "assemble.h"
#include "subtype.h"

bool is_subtype_for_defs(ast_t* sub_def, token_id sub_cap,
ast_t* super_def, token_id super_cap, pass_opt_t* opt)
{
ast_t* sub_type =
type_for_class(opt, sub_def, sub_def, sub_cap, TK_NONE, false);
ast_setdata(sub_type, sub_def);

ast_t* super_type =
type_for_class(opt, super_def, super_def, super_cap, TK_NONE, false);
ast_setdata(super_type, super_def);

bool result = is_subtype(sub_type, super_type, NULL, opt);

ast_free_unattached(sub_type);
ast_free_unattached(super_type);

return result;
}
15 changes: 15 additions & 0 deletions src/libponyc/type/subtype_ffi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef SUBTYPE_FFI_H
#define SUBTYPE_FFI_H

#include <platform.h>
#include "../ast/ast.h"
#include "../pass/pass.h"

PONY_EXTERN_C_BEGIN

bool is_subtype_for_defs(ast_t* sub_def, token_id sub_cap,
ast_t* super_def, token_id super_cap, pass_opt_t* opt);

PONY_EXTERN_C_END

#endif
4 changes: 3 additions & 1 deletion tools/corral.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"pony-doc",
"pony-doc/test",
"pony-dep",
"pony-dep/test"
"pony-dep/test",
"pony-agent-server",
"pony-agent-server/test"
],
"deps": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,29 @@ class CompileSession
_pass_opt.limit = limit()
@ast_passes_program(_raw, _pass_opt)

fun box is_sendable(type_ast: AST box): Bool =>
"""
True when the given type is sendable (iso, val, or tag).
Handles nominal, union, intersection, tuple, and arrow types.
"""
@sendable(type_ast.raw, _pass_opt)

fun box is_subtype(
sub_def: AST box,
sub_cap: TokenId,
super_def: AST box,
super_cap: TokenId)
: Bool
=>
"""
True when a nominal type built from `sub_def` at `sub_cap` is a
subtype of a nominal type built from `super_def` at `super_cap`.
Both definitions must be entity AST nodes (TK_CLASS, TK_ACTOR,
TK_PRIMITIVE, TK_TRAIT, TK_INTERFACE, TK_STRUCT).
"""
@is_subtype_for_defs(
sub_def.raw, sub_cap, super_def.raw, super_cap, _pass_opt)

fun ref dispose() =>
"""
Release pass_opt resources. Must be called when the session is no longer
Expand Down
8 changes: 8 additions & 0 deletions tools/lib/ponylang/pony_compiler/pony_compiler/types.pony
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
use @sendable[Bool](type_ast: Pointer[_AST] box, opt: _PassOpt box)
use @is_subtype_for_defs[Bool](
sub_def: Pointer[_AST] box,
sub_cap: I32,
super_def: Pointer[_AST] box,
super_cap: I32,
opt: _PassOpt box)

primitive Types
"""
AST type extraction utilities.
Expand Down
11 changes: 11 additions & 0 deletions tools/pony-agent-server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
project(tools.pony-agent-server)

# Generate version.pony from template
# (.gitignore prevents version.pony from dirtying the git tree)
configure_file(version.pony.in ${CMAKE_CURRENT_SOURCE_DIR}/version.pony @ONLY)

add_pony_binary(tools.pony-agent-server ALL
NAME pony-agent-server
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}
PATHS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../lib/ponylang/pony_compiler
WATCH ${CMAKE_CURRENT_SOURCE_DIR})
Loading
Loading