瀏覽代碼

Align container layout with AGENTS.md; document AxonASP gotchas

- docker-compose.yml mounts the repo at /opt/axonasp/site and serves
  public/ via SERVER_WEB_ROOT so gen.cmd/migrate.cmd work
- AGENTS.md/README.md: drop deploy/ references, add include-order,
  Eval/Execute, call-site binding and single-line If gotchas

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
pull/1/head
Daniel Covington 1 天之前
父節點
當前提交
875f7c6aca
共有 3 個檔案被更改,包括 27 行新增 和 25 行删除
  1. +17
    -13
      AGENTS.md
  2. +3
    -4
      README.md
  3. +7
    -8
      docker-compose.yml

+ 17
- 13
AGENTS.md 查看文件

@@ -2,32 +2,32 @@

Rules for developing Classic ASP applications that run on **AxonASP** (Go-based Classic ASP / VBScript 5.8 runtime, https://github.com/guimaraeslucas/axonasp).

Sources: the AxonASP manual (`deploy/www/manual/md`, notably `authoring/llm-classic-asp-coding.md`, `asp/*`, `asp-modernization/*`, `runtime/*`, `config/*`, `libraries/*`) plus problems verified while porting this project. Items marked **[verified here]** were reproduced in this repo's container; the rest come from the manual.
Sources: the AxonASP manual (in the container at `/opt/axonasp/www/manual/md`, notably `authoring/llm-classic-asp-coding.md`, `asp/*`, `asp-modernization/*`, `runtime/*`, `config/*`, `libraries/*`) plus problems verified while porting this project. Items marked **[verified here]** were reproduced in this repo's container; the rest come from the manual.

When unsure about an object, ProgID, method or config key, check `deploy/www/manual/md` before guessing. Do not invent APIs.
When unsure about an object, ProgID, method or config key, check `/opt/axonasp/www/manual/md` in the container before guessing. Do not invent APIs.

---

## 1. Project layout and how to run it

```
asp-classic-unified-framework/ the application (MVC starter, "RouteKit")
(repo root) the application (MVC starter, "RouteKit"), also the git repo root
public/ web root (Default.asp front controller + routes, web.config, api/*.openapi.json specs)
core/ framework code (autoload_core.asp, mvc.asp, lib.*.asp incl. lib.JsonLite.asp, helpers.asp)
app/ controllers/ (HTML: <Name>Controller, JSON: Api<Name>Controller), models/ (POBO_<T>, <T>Repository),
views/<Name>/
db/ app.sqlite (SQLite) and migrations/
db/ app.sqlite (SQLite, git-ignored) and migrations/
scripts/ migrate.cmd/.asp, gen.cmd (generators: migration, repo, controller, api), templates/ (POBO,
Repository, Api). Run through the AxonASP CLI in the container.
docker-compose.yml the AxonASP container (stock image ghcr.io/guimaraeslucas/axonasp)
api-tests/ created by `gen.cmd api`: <table>.http sample requests (VS Code REST Client)
deploy/ Dockerfile, docker-compose.yml, app/ (AxonASP linux binaries + config/axonasp.toml)
```

- Run: `cd deploy && docker compose up -d --build` -> http://localhost:8801
- Compose mounts the whole framework folder at `/opt/axonasp/site` and sets `SERVER_WEB_ROOT=/opt/axonasp/site/public`. This keeps `../core`, `../app`, `../db` reachable from `public/`.
- Run: `docker compose up -d` from the repo root -> http://localhost:8801
- Compose mounts the whole repo at `/opt/axonasp/site` and sets `SERVER_WEB_ROOT=/opt/axonasp/site/public`. This keeps `../core`, `../app`, `../db` reachable from `public/`, and is the layout `gen.cmd` / `migrate.cmd` expect (container name must be `axonasp`).
- Migrations: `scripts\migrate.cmd status|up|down` (runs `axonasp-cli` inside the container).
- Swagger UI for the JSON APIs: http://localhost:8801/api/docs (needs internet: loads Swagger UI from the jsDelivr CDN).
- `deploy/www/` is the stock AxonASP demo site and manual. It is not part of this app.
- The AxonASP manual is inside the container: `docker exec axonasp ls /opt/axonasp/www/manual/md` (libraries/, asp/, runtime/, ...). There is no `deploy/` folder in this repo.

### Adding a table end to end (the workflow that was verified)

@@ -89,7 +89,7 @@ The portable rules in section 2 remain the default for framework and application

## 5. Objects and libraries

Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `deploy/www/manual/md/libraries/overview.md`. Names are case-insensitive. AxonASP maps ProgIDs to native Go implementations; it does not use the Windows registry or COM.
Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `/opt/axonasp/www/manual/md/libraries/overview.md` (in the container). Names are case-insensitive. AxonASP maps ProgIDs to native Go implementations; it does not use the Windows registry or COM.

- **Prefer native libraries over hand-rolled ASP:** `G3JSON`, `G3DB`, `G3HTTP`, `G3CRYPTO`, `G3MAIL`, `G3FILES`, `G3TEMPLATE`, `G3MD`, `G3IMAGE`, `G3PDF`, `G3ZIP`, `G3FILEUPLOADER`, `G3STRINGBUILDER`, `G3AXON.FUNCTIONS`. **Exception:** do not use `G3JSON.Parse` in a request that also uses `G3DB` (see section 8); the API controllers use the pure-VBScript `core/lib.JsonLite.asp` instead.
- `Val()` is not usable in this build (Type mismatch even for "7"). Convert with `CDbl` (mind the locale decimal separator: JSON uses `.`).
@@ -113,7 +113,7 @@ Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `de

## 6. Configuration

- Server config: `deploy/app/config/axonasp.toml` (copied into the image). Any key can be overridden by an environment variable when `viper_automatic_env = true`: `[server] web_root` -> `SERVER_WEB_ROOT`, `server_port` -> `SERVER_SERVER_PORT`, `[global] default_mslcid` -> `GLOBAL_DEFAULT_MSLCID`, and so on. A different config file: `axonasp-http -c path.toml`.
- Server config: `/opt/axonasp/config/axonasp.toml` inside the container (stock image; override with env vars in `docker-compose.yml`). Any key can be overridden by an environment variable when `viper_automatic_env = true`: `[server] web_root` -> `SERVER_WEB_ROOT`, `server_port` -> `SERVER_SERVER_PORT`, `[global] default_mslcid` -> `GLOBAL_DEFAULT_MSLCID`, and so on. A different config file: `axonasp-http -c path.toml`.
- **web.config is processed only if `enable_webconfig = true`, only from the web root, and only a subset of IIS** (`rewrite`, `httpRedirect`, `httpErrors`, and appSettings read by app code). Subdirectory web.config files are ignored.
- Rewrite patterns use **Go RE2: no lookahead (`(?!...)`), no backreferences.** **[verified here]** a lookahead rule silently never matched. To exclude static files, use the `IsFile` / `IsDirectory` conditions instead. Supported condition inputs: `{REQUEST_FILENAME}`, `{URL}`, `{REQUEST_URI}`. Rewrites run before ASP execution. After a rewrite the server's `URL` is the rewritten target, so pass the original path in the query string (`__route`), as `public/web.config` does.
- Application settings come from `GetAppSetting("Key")` (reads `web.config` appSettings). Keep secrets out of source control; prefer environment variables for credentials.
@@ -149,6 +149,10 @@ Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `de
- **Static files under `public/`** (for example `public/api/*.openapi.json`) are served directly; the rewrite rule skips existing files and directories. Only routes in `public/Default.asp` go through the MVC dispatcher; a route needs the controller in `autoload_controllers.asp` **and** in `ControllerRegistry` (the generators do both).
- **Swagger UI:** the multi-spec dropdown (`urls: [...]`) only works with `presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset]` and `layout: "StandaloneLayout"`. Without them the page says "No API definition provided".
- **Git Bash:** `curl` sends non-ASCII literals as cp1252, not UTF-8 (use `ü` escapes or a file with `--data-binary @file`); read CSRF tokens from the form with a cookie jar (`-c/-b`); strip `\r` from values printed by Python on Windows before putting them in URLs.
- **Include order matters for class methods.** A class method cannot see a global Function/Class defined in a file included *after* the class's file (`GetRouter()`, `Flash()` failed with "Object required" / "doesn't support this property or method"). `core/autoload_core.asp` therefore includes `mvc.asp` last.
- **Dynamic Eval/Execute in classes is unreliable.** `Eval`/`Execute` inside a Class method cannot see global functions; with a runtime-built string they re-emit a method's inline HTML twice (second copy after the footer); `CallByName` is a silent no-op. Do not dispatch with them.
- **Call sites bind to the first class.** `CurrentController.Invoke ...` in one place was bound to the first controller's `Invoke` and reused for every later controller (the first dispatched action's body appeared on every route; title/layout were right). Each controller therefore exposes a global `<Name>Controller_Invoke(actionName, args)` and the dispatcher calls it through `GetRef` (`MVC_InvokeAction`). New controllers must define `Invoke` and `<Name>Controller_Invoke` (the generators emit both).
- **Single-line `If x Then a = b Else a = c` swallowed the rest of a Sub** under `On Error Resume Next`. Always use multi-line `If`.
- **Class member vs local name clash.** Avoid a local `Dim controllerName` inside a class that also has a `ControllerName` property.
- **`Empty Is Nothing` raises "Object required".** Test with `IsObject` / `IsEmpty` first, then `Is Nothing`.
- **`Server.Execute(file)` runs the file as a separate page.** It does not define procedures in the caller's scope. To load a script's Subs, read the file and `ExecuteGlobal` the text (strip `<%`/`%>`), as the migrator does.
@@ -164,7 +168,7 @@ Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `de
- Parameterize SQL. Never accept table or column names from users.
- `Server.HTMLEncode` all output derived from input, headers, DB data and errors.
- Do not show `ASPError` details (file, line, source) to end users in production. Log them instead; custom pages go through `httpErrors` in `web.config`.
- Keep `blocked_extensions` / `blocked_dirs` in `axonasp.toml` intact. Do not place secrets, `.sqlite` files or migrations under the web root (`public/`).
- Keep `blocked_extensions` / `blocked_dirs` in the container's `axonasp.toml` intact. Do not place secrets, `.sqlite` files or migrations under the web root (`public/`).
- Do not enable `allow_external_filesystem_access` unless a trusted need is documented.
- Use `G3CRYPTO` for hashing and tokens. Do not roll your own.
- The generated JSON APIs are **unauthenticated and have no CSRF protection** (stateless by design). Put authentication in front of them before exposing the app, and keep HTML form posts on the CSRF token (`HTMLSecurity()`).
@@ -174,7 +178,7 @@ Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `de
## 10. Working rules for agents in this repo

- **Use the provided scripts; do not hand-create what they generate.** New migration -> `scripts\gen.cmd migration`; model + repository -> `scripts\gen.cmd repo`; JSON API (controller, routes, whitelist, includes, OpenAPI spec, `.http` file) -> `scripts\gen.cmd api`; HTML controller stub with routes -> `scripts\gen.cmd controller`; schema changes -> `scripts\migrate.cmd up|down|status`. Edit generated files afterwards (migration bodies, business rules, views), but never write a controller, repository, POBO, route, whitelist entry or migration file from scratch when a generator exists, and never change the schema outside a migration. If a generator is missing a feature or produces something wrong, fix the generator/template in `scripts/` (and say so) instead of patching the output only.
- **The scripts need Docker.** `gen.cmd` and `migrate.cmd` run `docker exec ... axonasp ./axonasp-cli`, so Docker must be running and the `axonasp` container up (`cd deploy && docker compose up -d`) before using them. If it is not running, start it or tell the user; do not fall back to hand-writing the files. Run them from PowerShell or cmd, not Git Bash. Generators only write files: `docker restart axonasp` afterwards.
- **The scripts need Docker.** `gen.cmd` and `migrate.cmd` run `docker exec ... axonasp ./axonasp-cli`, so Docker must be running and the `axonasp` container up (`docker compose up -d` from the repo root) before using them. If it is not running, start it or tell the user; do not fall back to hand-writing the files. Run them from PowerShell or cmd, not Git Bash. Generators only write files: `docker restart axonasp` afterwards.
- Make the smallest change that solves the problem. Match the style of the file you are editing.
- After changing ASP code, restart the container, then verify in the running app (`curl localhost:8801/...`) before claiming success. Report real output and real errors.
- Test every new endpoint through the whole range: happy path, validation (422), bad input (400), unknown id (404), wrong method (405), HTML-escaping, UTF-8 round trip, and a cold first request after a restart. JSON APIs: curl, the generated `api-tests/<table>.http` and the Swagger page `/api/docs`.
@@ -182,5 +186,5 @@ Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `de
- When a bug does not make sense, stop patching around it: reduce it to a small page, change one variable at a time, and write the finding into section 8.
- Do not add `On Error Resume Next` to silence an error. Surface it.
- Keep new code to the portable subset in section 2 unless the user asks for AxonASP extensions.
- Do not modify `deploy/www/` (stock demo and manual) or `deploy/app/` binaries.
- Do not modify anything under `/opt/axonasp` in the container except the mounted `site/` folder.
- Ask before deleting migrations, the database file, or anything under `db/`.

+ 3
- 4
README.md 查看文件

@@ -9,8 +9,7 @@ No sample modules are included: the first table you add is yours.
Requires Docker.

```
cd deploy
docker compose up -d --build
docker compose up -d
```

Open http://localhost:8801. The compose file mounts this folder into the container and serves `public/`.
@@ -30,7 +29,7 @@ db/
migrations/ YYYYMMDDHHMMSS_name.asp (Migration_Up / Migration_Down)
app.sqlite created by the first migration run (git-ignored)
scripts/ gen.cmd (generators), migrate.cmd, templates/
(deploy/ with the Dockerfile and docker-compose.yml currently sits next to this folder, outside this git repo)
docker-compose.yml the AxonASP container (mounts this folder at /opt/axonasp/site)
```

## Adding a feature
@@ -53,7 +52,7 @@ The Swagger UI at http://localhost:8801/api/docs lists every generated API spec
## Configuration

- `public/web.config`: `ConnectionString` (`sqlite:/opt/axonasp/site/db/app.sqlite`), environment and UI settings.
- `deploy/app/config/axonasp.toml`: server settings; any key can be overridden with an environment variable (see `deploy/docker-compose.yml`).
- `/opt/axonasp/config/axonasp.toml` (inside the container): server settings; any key can be overridden with an environment variable (see `docker-compose.yml`).

## Rules for developers and AI agents



+ 7
- 8
docker-compose.yml 查看文件

@@ -4,13 +4,12 @@ services:
container_name: axonasp
ports:
- "8801:8801"
environment:
# The whole repo is mounted at /opt/axonasp/site so ../core, ../app and ../db
# stay reachable from public/. web.config points SQLite at
# /opt/axonasp/site/db/app.sqlite. The generators (scripts/gen.cmd) and the
# migrator (scripts/migrate.cmd) also expect this layout.
SERVER_WEB_ROOT: /opt/axonasp/site/public
volumes:
# Web root
- ./public:/opt/axonasp/www
# Default.asp includes ../core/... relative to the web root
- ./core:/opt/axonasp/core
# core/mvc.asp includes ../app/models, controllers and views
- ./app:/opt/axonasp/app
# web.config points SQLite at /opt/axonasp/site/db/app.sqlite
- ./db:/opt/axonasp/site/db
- .:/opt/axonasp/site
restart: unless-stopped

Loading…
取消
儲存

Powered by TurnKey Linux.