Skip to content

The command line and application files ​

The pgkiln command line runs migrations, exports and imports applications, and compares an application with files in git (APEX: SQLcl apex export and the APEXlang application files). An application can be exported as one JSON file or as a directory with one file per component that reads well in pull requests, and imported again, as a copy or over the existing application.

Running it ​

From a pgkiln checkout (it runs TypeScript with tsx, like the server):

sh
npm run pgkiln -- apps               # through npm
npx tsx src/cli/main.ts apps         # directly
./bin/pgkiln.js apps                 # the package's bin entry (also after npm link)

Without a checkout, from the npm package or in the Docker container:

sh
npx -y pgkiln apps                                       # npm (Node.js 20+); or npm install -g pgkiln, then: pgkiln apps
docker compose exec pgkiln node bin/pgkiln.js apps       # the Docker installation (from the directory with compose.yaml)

It connects with DATABASE_URL (the owner role) from the environment or .env, the same as the server and npm run db:migrate; --db <url> overrides it. Every command has --help. (sprint 194) The exception is pgkiln mcp --url, which needs no database: it works through the builder's API with a developer's builder token, so a developer's own machine never holds the owner connection.

Exit codeMeaning
0done; for diff: no differences
1diff found differences
2usage error (unknown command or option, missing argument, alias already taken)
3failure (application not found, database error, invalid files)

Errors go to standard error. The CLI never prints passwords or hashes; the exports don't contain any (see what is not exported).

Commands ​

CommandWhat it does
pgkiln migrate [--example <name>]Applies the migrations that were not applied yet, then optionally examples/<name>/ (same as npm run db:migrate / npm run example:hr; --root and --seed as in scripts/migrate.ts)
pgkiln apps [--json]Lists the applications: alias, number of pages, name
pgkiln export <alias> [--format json|dir|text] [--out <path>]json (default): the pgkiln/2 document with sorted keys, to --out or standard output. dir: a directory (default ./<alias>), see below. text: the same directory in YAML with the code inline (text files)
pgkiln import <path> [--alias <alias>] [--replace [--only <file>]…] [--check [--force] | --dry-run]Imports a JSON export, an application directory or a .zip of one. --alias gives the copy another alias. --replace updates the application with that alias in place (after a backup); with --only pages/12 (repeatable) only that page or component file (below). --check checks the application before it commits, --dry-run only checks (below)
pgkiln import-apex <f100.sql|dir|zip> [--alias <alias>] [--schema <schema>] [--db-role <role>] [--dry-run | --out <dir>] [--json] [--all](sprint 182) Imports an Oracle APEX application export in the SQL format and prints the import report: what each component became, what needs porting, what was not mapped. --dry-run only reports; --out writes the application files to edit first (chapter 11)
pgkiln diff <alias> <path> [--name-only | --quiet]What differs between the application in the database and a directory (or JSON file, or zip)
pgkiln advise <path|alias> [--offline] [--format text|json|sarif] [--fail-on error|warning|info|never] [-o <file>] [--base <dir>](0.77) The Advisor for CI: an export is imported into a transaction that is always rolled back and checked there; an alias checks the application in the database. --offline checks an export's files without a database. SARIF points each finding at its file, so pull requests get annotations. Exit code 1 from --fail-on (default error) (below)
pgkiln working-copy list|create|compare|merge|refresh|delete <alias> [<name>] [--prefer copy|main] [--take <component>]… [--as <developer>](0.77) Working copies from the command line (below)
pgkiln lock <alias> [--page <n>] [--note <text>] / pgkiln unlock <alias> [--page <n>] [--force](0.77) The builder's application and page locks; another developer's lock is broken only with --force (logged)
pgkiln ddl <schema> [--no-comments] [--no-grants] [--out <file>]The DDL of a schema's objects, in an order that runs (as SQL Workshop → DDL, chapter 3)
pgkiln compare <source> <target> [--script]Compares two schemas: + only in the source, - only in the target, ~ different; exit code 1 when they differ. --script writes the script that makes the target like the source (drops commented out); nothing is run
pgkiln mcp [--url <address> [--token-env <variable>]]An MCP server on standard input/output for AI coding agents, see chapter 20. (sprint 194) With --url it acts as the developer whose builder token is in the environment variable (default PGKILN_TOKEN), through the builder's API: no DATABASE_URL, only the token's scopes and workspace (remote, with a builder token)
pgkiln plugin build <dir> [-o <file>]Builds a plug-in file (pgkiln-plugin/2) from a source directory, see plug-ins
pgkiln plugin install <file|dir> --app <alias> [--replace]Adds a plug-in (file or source directory) to an application; its install SQL is not run
pgkiln users list [--developers]Accounts with their applications and roles, or builder developers
pgkiln users add <username> [--developer] [--app <alias> --roles a,b] [--name …] [--email …]Adds an account (optionally with access to an application) or a builder developer
pgkiln users password <username> [--developer]Sets a password and ends that user's sessions; (sprint 194) a developer's builder tokens are revoked too
pgkiln admin reset-2fa <developer> [--reason <text>](0.60) Removes a developer's authenticator apps and recovery codes and ends their builder sessions: locked out?; (sprint 194) and revokes their builder tokens
pgkiln admin set-2fa-policy off|admins|all [--grace <days>](0.60) Sets the builder's two-factor policy; off always works (and, 0.62, clears every workspace's own rule), the others need two administrators with an app
pgkiln admin builder-sign-in password(0.63) Turns off every workspace's single sign-on rule, so developers may sign in with the pgkiln password again; logged and mailed to the administrators
pgkiln admin rotate-key [--dry-run](0.67) Re-encrypts every stored secret from PGKILN_OLD_SECRET_KEY to PGKILN_SECRET_KEY in one transaction (rotating the instance key); logged and mailed to the administrators
pgkiln admin key-backed-up(0.67) Records that a copy of the current PGKILN_SECRET_KEY is kept outside the server
pgkiln admin check [--url <address>] [--production](0.67) Prints the lockout checks; --url checks passkeys against a new public address. Exit code 1 when one needs attention. (sprint 191) --production adds the production readiness group (shown anyway when PUBLIC_URL is an https address), for a deploy pipeline
pgkiln admin demote-owner [--dry-run](0.112) Makes DATABASE_URL's role pgkiln's owner without SUPERUSER, on the superuser connection SUPERUSER_DATABASE_URL: the role, the database and the old owner's objects, ADMIN OPTION on pgkiln's roles, pg_cron, and SUPERUSER taken from the old owner, in one transaction that refuses to lock pgkiln out (a non-superuser owner). --dry-run prints the statements; running it again changes nothing

users reads the password from standard input (the first line, e.g. from a secret store: printf '%s\n' "$PW" | pgkiln users add ops --developer) or asks for it twice on a terminal. It is never an argument, so it doesn't end up in the shell history, and it must meet the password policy.

The directory format ​

pgkiln export hr --format dir writes:

hr/
  pgkiln.json                       {"format": "pgkiln/2", "layout": 1}
  app.json                          the application's settings (app.pwa_icon.png next to it)
  navigation.json                   the navigation menu as a tree
  shared/
    authorizations/manager.json
    app-items/ai_ename.json
    app-processes/0010-link-user-to-employee.json
    app-processes/0010-link-user-to-employee.code.sql
    app-computations/0010-ai_region-after_authentication.json   (by sequence, item and point)
    component-groups/sales_lookups.json
    report-queries/orders_by_region.json   (the query in .query.sql)
    shortcuts/delete_confirm_msg.json   (a long value in .value.txt, .html or .sql by its type)
    lovs/jobs.json
    lovs/jobs.query.sql
    report-layouts/hr_directory.json   (a logo as hr_directory.logo.png)
    template-components/status_badge.json   (named by static id; the template in status_badge.template.html)
    automations/ document-templates/ task-definitions/ workflow-definitions/ rest-modules/
    web-credentials/ rest-sources/      (web credentials never contain their secret)
    lists/hr_shortcuts.json           (a query list's query in hr_departments.query.sql)
    list-entries.json                 the entries of every list, per list as a tree
    automation-actions/remind-managers/0010-remind-the-manager.json   (per automation; code in .code.sql, condition in .condition.sql)
    supporting-objects/check-the-sample-data.json   (the script in .script.sql; never run on import)
    plugins/log_event.json            (install SQL in log_event.install_sql.sql; never run on import)
    group-roles.json
  globalization/
    text-messages.json
    translations/nl.json
  static/
    files.json                      the static application files and their types
    hr.js  hr.css                   each file as itself
  pages/
    0003-employees-form/
      page.json
      regions/0010-employees.json
      items/0020-p3_ename.json
      buttons/0030-save.json
      dynamic-actions/0020-suggest-a-salary-for-the-job.json
      dynamic-actions/0020-suggest-a-salary-for-the-job.code.sql
      validations/0010-commission-only-for-sales.json
      validations/0010-commission-only-for-sales.expression.sql
      processes/0010-process-form-employees.json
  extra/                            sections of newer pgkiln versions this one does not know
  • One file per component, named <sequence>-<static id>.json (pages: <page number>-<name>; shared components: their name). The JSON holds the component's row as in the meta table, with sorted keys, two-space indentation, LF line ends and a final newline, so diffs show only real changes and a re-export of an unchanged application rewrites nothing.
  • Code in its own file: SQL, PL/pgSQL and templates that are longer than 60 characters or span lines move to <base>.<column>.sql (.html for static content and document templates) next to the JSON; the column is then left out of the JSON. Short values stay inline. Either way imports.
  • No database ids. Components refer to each other by static id: an item, button or process says "region": "employees", a dynamic action "affected_region": "…", a facet or map region "report": "employees" in its settings, (sprint 195) a sub region"parent": "details" (a region at page level has no parent). Navigation entries are nested instead of pointing at parent ids. A directory exported from two installations of the same application is identical.
  • Binary values (a report layout's logo, the PWA icon) are written as image files, and static application files as themselves under static/ (listed in static/files.json).

Edit the files with any editor and import them again; the directory is the source of truth for the application, the database objects (tables, views, functions) stay in your own migration scripts.

Keys you leave out (hand-written files) ​

An export writes every column of every component, but a file you write by hand (or generate from another tool) doesn't have to. On import, a key that is absent takes the column's default, read from the database's catalog for every kind of component: leave debug out of app.yaml and the application gets debug: false; leave protection and requires_auth out of a page.yaml and the page gets checksum and true; leave seq out of an item and it gets 10. Two rules keep this predictable:

  • Absent is not null. Only a key that is missing is filled. A key that is present with null (protection: null, or protection: with nothing after it) stays null, and a column that may not be null refuses it as before.
  • Constant defaults only. Literals such as 'checksum', false, 10, {} or []. Ids, references (region, parent), and what an export leaves out on purpose (the application's build status and availability, web credentials' secrets, an automation's next run) are never filled.

The defaults are those of a new component in the builder, and the security ones are the strict ones: a page that doesn't say requires_auth needs a sign-in, one that doesn't say protection gets checksum protection, an application that doesn't say access_control admits only assigned users. With import --replace, a key you leave out is set to its default, not kept at the installed value.

A missing key never widens access. A few columns default to the open value, so they are never filled: a file must give them, and when one is missing (or null) the import is refused with the file, the component and the key, and nothing changes. They are a REST module's roles (none: any token may call it) and enabled, a web credential's valid_for (none: sent to any URL), and the application's mfa, mfa_roles and local_login. An export always has them. An export made by an older pgkiln, from before such a column existed, still imports as it did: a component that has none of the keys added together with the column (a REST module without templates, from before 0.49; an application without mfa, mfa_roles or any setting added after them, from before 0.64) gets the default, which is what that version meant (no module roles, no second factor). A component that has those keys was written by a pgkiln that had the column, so its missing key is an omission and is refused.

import lists what it filled, per file, so you can see it (an export has every key, so a normal import lists nothing):

Filled from column defaults (keys the files leave out):
  app.yaml: debug, mfa
  pages/0003-employees/page.yaml: protection, requires_auth

pgkiln advise notes the same as INFO findings at their file, and diff compares a key that is left out as the default the import would give it, so leaving out a key whose value is the default shows no change. A column that may not be null and has no default (a list of values' query, an application's name) must be in the file; when it isn't, the import names the file, the component and the key:

shared/lovs/jobs.yaml (lov jobs): "query" is missing: meta.lov.query may not be null. Give the key a value (…)

When an import is refused ​

(sprint 251) An import reads every component into its table, and PostgreSQL refuses a value that isn't of the column's type, two components with one unique key, or a value a check constraint doesn't allow. The import (pgkiln import, the MCP tool import_app, the builder's Import, pgkiln advise) then names the file, the component, the key and its value instead of PostgreSQL's own message, lists every such problem of the files at once, and changes nothing:

The import was refused, nothing changed:
  - pages/0002-employees/buttons/0010-create.yaml (page 2, button CREATE): "target_page" is "&P11_BACK.": meta.button.target_page takes a whole number. A substitution (&ITEM.) or bind variable (:ITEM) is not evaluated in this property: give the value itself.
  - 2 items have the name "P3_ENAME" on page 3: pages/0003-employees-form/items/0020-p3_ename.yaml (page 3, item P3_ENAME) and pages/0003-employees-form/items/0021-p3_ename.yaml (page 3, item P3_ENAME); the unique key item_page_id_name_key allows one. Rename or remove one of them.
  - pages/0003-employees-form/processes/0015-start-onboarding.yaml (page 3, process Start onboarding): "point" is "before_header"; meta.process.point allows submit, load, ajax. "before_header" is the point of app computations, branches and computations, not of a process. A process that runs when the page is shown has point "load".
  • Types: a whole number, a number or true/false where the column wants one (PostgreSQL's own rules: " 12 " and "yes" are fine, "3.5" for a whole number is not).
  • Allowed values: the key's allowed values, a did you mean for a value in the wrong case, and for a value another kind of component has (a computation's before_header on a process) which kind that is and what to use.
  • Conditions: what the condition type needs (the SQL, the item's name, the value) or the list of condition types.
  • Unique keys: both files of two components with one key (two items of one name on a page, two regions of one static id, two pages of one number). A conflict with a row that is already in the database says so, without showing that row: the messages are made from your files and from pgkiln's own catalog (column types, constraint names and their allowed values), never from another application's or workspace's data.
  • Any other check: the component, the check's definition and the values of its keys.

A JSON document (the builder's Import, the builder API) has no files: the message names the component (page 2, button CREATE).

condition or condition_expr. A region's and a button's SQL condition is the key condition; every other component's (items, processes, validations, computations, branches) is condition_expr. An import takes either key on any of them and gives the column the one its table has; diff compares them the same way, and an export keeps writing the table's own key. A component that gives both with different values is refused, naming the file.

Text files (APEXlang) ​

APEX 26.1 writes applications in APEXlang, a human-readable text format. pgkiln export hr --format text writes the same directory with every component as YAML instead of JSON, and the SQL, PL/pgSQL and templates inline as literal blocks, so a region with its query, or a process with its code, is one file you read top to bottom:

yaml
config:
  link:
    column: empno
    items:
      P3_EMPNO: "#empno#"
    page: 3
seq: 10
source: |2-
  select e.empno, e.ename, e.job, d.dname as department
    from hr.emp e
    left join hr.dept d on d.deptno = e.deptno
static_id: null
title: Employees
type: report

The files are a strict subset of YAML 1.2 that any YAML tool reads: block mappings and lists, plain or double-quoted strings (JSON escapes), numbers, true/false/null, and literal blocks (|2-) for text over several lines; keys are sorted. pgkiln reads exactly that subset back, so anchors, tags, flow collections ([a, b], {a: 1}) and folded blocks are refused with the file and line; # comment lines are allowed (they are not kept by the next export). Text that could be read as something else (yes, 10, 2026-01-01, a: b) is written in double quotes. pgkiln.json stays JSON and says "style": "text".

import, diff and the builder's zip read JSON and YAML files alike, file by file, so a directory may mix them (the same component as both .json and .yaml is refused). diff exports the application in the directory's style, and compares YAML and JSON files by content. Switching an existing directory from dir to text (or back) rewrites every file once.

Static ids ​

APEX 26.1 gives components a static id so that application files diff cleanly and can be applied to another installation. pgkiln derives them without a schema change, from what already identifies a component:

ComponentStatic id
pageits page number
regionits Static ID when it has one (0.31: an optional region attribute, unique on the page), else its title as a key (Who's out this week → who-s-out-this-week), its type when it has no title; -2, -3 for duplicates on a page
item, button, dynamic action, validation, processits name as a key (P3_ENAME → p3_ename), else its label, event and action, item or type
shared componentstheir name

A key is lower case a-z, 0-9, _ and -. The static id is the part of the file name after the sequence number; renaming a region without a stored Static ID renames its file in the next export (give regions that others refer to a Static ID to keep their files, references and, with import --replace, the users' saved reports stable). When you edit the files by hand, keep a reference and the file name of the region it points at in step: import and diff report a reference to a region that doesn't exist on the page.

Updating an application in place ​

pgkiln import hr/ --replace makes the application with alias hr look like the directory: its settings, pages and shared components are those of the files, and components that are not in the files any more are removed. What belongs to this installation stays:

  • the application's id and alias (links, API URLs and bookmarks keep working),
  • who may sign in and with which roles (accounts are never exported; identity-provider group mappings do come from the file), OAuth clients, sessions and "keep me signed in" tokens,
  • saved reports of users (and their grid column layouts), which move to the new version of their region (same page number and static id),
  • running tasks and workflows, which keep their definition (by name),
  • for automations: whether each one is switched on, its next and last run, and its log. New automations arrive switched off, as with every import.
  • the secrets of web credentials with the same name (exports never contain them; see chapter 19).
  • the style variant each user chose (chapter 14); a style that the file no longer has falls back to the default.
  • its availability and build status (chapter 3): exports leave them out, so a deployment doesn't open an application you closed, or close one;
  • its backups: the version the import replaces is the newest one (chapter 3).

It all happens in one transaction; any error leaves the application unchanged. Without an application with that alias, --replace simply imports, so the same command deploys the first time and every time after.

A typical flow with git:

sh
pgkiln export hr --format dir --out apps/hr     # in development, after changes in the builder
git diff apps/hr                                 # review, commit, open a pull request
pgkiln diff hr apps/hr                           # on the target: what would change (exit code 1)
pgkiln import apps/hr --replace                  # deploy

Importing one page or component ​

(sprint 116; APEX 26.2: APEXlang file-level import) With --replace, --only imports just the named files of a directory export (or a .zip of one) and leaves the rest of the application as it is in the database:

sh
pgkiln import apps/hr --replace --only pages/12                 # page 12 with its regions, items, buttons …
pgkiln import apps/hr --replace --only shared/lovs/jobs.yaml    # one shared component
pgkiln import apps/hr --replace --only pages/12 --only shared/lovs   # several: repeat --only

pages/12 (or just 12) is page 12's folder whatever its name, so a renamed page still matches; any other value is a file or folder path inside the export. A page or file that the directory no longer has is removed from the application. How it works: pgkiln exports the application in the directory's style, takes the named files from the directory, and imports the result with --replace as usual: one transaction, a backup first, --check and --dry-run work the same, and what belongs to the installation is kept. It says how many of the named files differ (on standard error). --only refuses without --replace, for a JSON file, for a path outside the export and for a selection that matches nothing in the directory or the application (exit code 2). A component that another file refers to by name (a list of values used on a page, say) has to exist after the import, as with any import.

Checking before an import ​

An import doesn't need the application's tables, columns and functions to exist (neither does APEX's): a page whose SQL names a missing table imports fine and fails when it runs. --check asks the Advisor first, inside the import's transaction, before anything is committed: every SQL fragment is planned as the application's database role (unknown tables, columns, functions and types, missing grants), PL/pgSQL blocks are compiled, and references to pages, items, lists of values, schemes and search configurations are checked.

sh
pgkiln import apps/hr --replace --check      # errors: nothing changes, exit code 1
pgkiln import apps/hr --replace --dry-run    # only check (exit code 0 without errors)
pgkiln import apps/hr --replace --check --force   # report, import anyway
text
ERROR  page 2, region Employees (Source): relation "hr.employee" does not exist
WARNING  page 3, item P3_SAL (Default value): …
Check: 1 error(s), 1 warning(s), 0 note(s).
Not imported: the check found 1 error(s). Fix them, or use --force.

Deploy the database changes (your migration scripts) before the application, so the check sees the tables the new version needs. The MCP server's import_app checks by default; the builder's Import page has the check ticked.

export --format dir into an existing directory removes the files of deleted components and leaves dot files (.git, .gitattributes) alone; it refuses a non-empty directory without a pgkiln.json, so a typo can't empty the wrong folder.

pgkiln advise in CI ​

(sprint 144; APEX 26.2: APEXlang static analysis with SQLcl CodeScan) pgkiln advise runs the Advisor outside the builder: every SQL fragment planned as the application's role, the references, and the security checks (pages that write data without sign-in or an authorization scheme, unrestricted page protection, long sessions, administrators without a second factor). Given a path (directory, .zip or JSON export), it imports the application under a temporary alias in a transaction that is always rolled back: nothing changes, and process code, supporting objects and plug-in SQL are never run. Given an alias, it checks the application in the database (also rolled back).

It needs a database: pgkiln's migrations for the meta schema, and the application's own tables, so the SQL plans against what the new version needs. In CI that is a PostgreSQL service, pgkiln migrate and your own migrations:

yaml
# .github/workflows/pgkiln.yml
jobs:
  advise:
    runs-on: ubuntu-latest
    permissions: { contents: read, security-events: write }
    services:
      postgres:
        image: postgres:17
        env: { POSTGRES_USER: pgkiln, POSTGRES_PASSWORD: pgkiln, POSTGRES_DB: pgkiln }
        ports: ['5432:5432']
        options: --health-cmd pg_isready --health-interval 2s --health-retries 30
    env:
      DATABASE_URL: postgres://pgkiln:pgkiln@localhost:5432/pgkiln
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npx pgkiln migrate
      - run: psql "$DATABASE_URL" -f db/schema.sql          # your application's tables
      - run: npx pgkiln advise apps/sales --format sarif -o advise.sarif --fail-on warning
      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with: { sarif_file: advise.sarif }

Without a database (sprint 147): pgkiln advise <path> --offline reads the export's files and runs the checks that need no database: references between components (pages, items, lists of values, authorization schemes, build options, report layouts, regions, workflow definitions and steps, processes in chains), the login page and page groups, the pages' security defaults (writing without sign-in or a scheme, unrestricted protection), process settings and JSON source profiles, and (sprint 251) what an import would refuse: values of the wrong type, values a check doesn't allow, conditions and unique keys given twice, each an error at its file (the import refuses this), checked against the schema of the pgkiln that runs it. It never connects (DATABASE_URL may be unset), so it fits a quick step before the full check, or a repository without a database in CI:

yaml
      - run: npx pgkiln advise apps/sales --offline --format sarif -o advise.sarif

Offline, SQL is not planned (it needs the application's tables and role), nothing is read from the catalog (vector and full-text columns, JSON source views, plpgsql_check), and the workspace's remote servers and credentials, branches to other applications, the installation's session limits and the administrators' second factor are not checked. The summary line says checked offline, and JSON output has "offline": true. The findings are the same as the full check's for everything it does check.

FormatWhat it gives
text (default)one finding per line with its file under it, and a summary line
json{ alias, checked, offline, counts: { error, warning, info }, findings: [{ severity, where, field, message, page, kind, file }] }
sarifSARIF 2.1.0: a result per finding with its level (error, warning, note), a stable rule id (pgkiln/region/source) and the file of its page or component in the export (apps/sales/pages/0002-orders/regions/0010-order-list.yaml), so GitHub code scanning annotates the pull request

The paths are relative to the current directory. With an alias there is no directory: --base apps/sales names the folder its export is kept in. --fail-on sets the exit code: 1 when a finding is at that level or worse (error by default; never always 0); 2 for a usage error, 3 when the database can't be reached.

Working copies and locks ​

(sprint 144; APEX 26.2: the Application and Working Copy APIs) The builder's working copies and locks, for scripts and CI:

sh
pgkiln working-copy create sales "feature x" --as alice   # Working copy feature x of sales: application sales-feature-x (812)
pgkiln export sales-feature-x --format text -o apps/sales-feature-x   # change the copy's files …
pgkiln import apps/sales-feature-x --replace --check
pgkiln working-copy compare sales-feature-x                # copy / main / CONFLICT per component, exit 1 with conflicts
pgkiln working-copy merge sales-feature-x --take pages/0002/page --as alice
pgkiln working-copy delete sales-feature-x
pgkiln lock sales --page 2 --note "release 1.4" --as alice
pgkiln unlock sales --page 2 --as alice

A merge needs a choice for every conflict (a component changed in both): --prefer copy or --prefer main for all of them, or --take <component> (as compare lists them) for each that keeps the copy's version. It is refused while another developer has locked the target application or a page it changes, as in the builder. Changes go to the activity log under --as, else PGKILN_DEVELOPER, else the operating system user. The MCP server has the same as the tools advise_app, working_copy and lock_app (chapter 20).

diff ​

pgkiln diff hr apps/hr exports the application in memory and compares file by file:

M pages/0002-employees/regions/0010-employees.source.sql
--- database/pages/0002-employees/regions/0010-employees.source.sql
+++ directory/pages/0002-employees/regions/0010-employees.source.sql
@@ -1,3 +1,4 @@
 select empno, ename, job
   from hr.emp
+ where active
A shared/lovs/locations.json
D pages/0009-audit-trail/page.json

A: only in the directory (an import adds it), D: only in the database (an import with --replace removes it), M: different. JSON files compare by content, so key order and spacing don't count. --name-only lists the files, --quiet only sets the exit code (for CI). An imported copy differs from its source in app.json (the alias) and in automations' enabled. (sprint 242) A key a hand-written file leaves out compares as its column default, the value an import gives it (keys you leave out): only a left-out key whose default differs from the application's value shows as a change.

In the builder ​

Export in the builder downloads the JSON file. /builder/apps/<id>/export?format=dir (or ?format=text) downloads the directory format as a .zip (one folder named after the alias, fixed timestamps, so the same application gives the same zip). pgkiln import hr.pgkiln.zip and pgkiln diff read the zip directly.

For pgkiln developers ​

  • src/appfiles.ts turns a pgkiln/2 document into files and back (pure functions, used by the CLI and the builder); meta.export_app() and meta.import_app() stay the only exporter and importer. A new section or column needs nothing here: unknown sections go to extra/, unknown columns stay in the component's JSON, unknown arrays of a page in page.json.
  • src/cli/replace.ts (--replace) lists which tables of an application are its definition (replaced) and which belong to the installation (kept). A new table that references meta.app or a component must be added there; test/cli.test.ts fails until it is, like the export test.
  • test/cli.test.ts covers help and exit codes, the round trip directory → import → export, diff and replace.

Released under the Apache-2.0 license. Not affiliated with Oracle; Oracle and APEX are trademarks of Oracle.