Imported from LnYo-Cly/ai4j (
AGENTS.md). Install upstream withnpx skills add LnYo-Cly/ai4j. Copyright stays with the author.
Repository Guidelines
Project Identity
- Project:
ai4j-sdk - Repository type: Java 8 Maven monorepo with adjacent docs and demo surfaces
- Primary language: Java
- Build tool: Maven
- Frontend/docs surfaces:
docs-site/andai4j-flowgram-webapp-demo/
Monorepo Scope
Treat this repository as a 10-module monorepo plus docs/demo surfaces.
| Path | Role |
|---|---|
ai4j-extension-api/ |
Lightweight public extension contract: manifest, ServiceLoader discovery, explicit enable/expose gates, extension resources |
ai4j-plugin-ask-user/ |
Official sample plugin package: host-mediated user clarification tool, command, Skill, and Prompt |
ai4j/ |
Core SDK: provider access, Chat/Responses, RAG, MCP, vector, image, audio, realtime |
ai4j-agent/ |
Agent runtime, workflow, trace, memory, subagent/team orchestration |
ai4j-coding/ |
Coding-agent runtime, workspace-aware tools, outer loop, compaction |
ai4j-cli/ |
CLI, TUI, ACP host, session/runtime integration |
ai4j-spring-boot-starter/ |
Spring Boot auto-configuration for core SDK |
ai4j-flowgram-spring-boot-starter/ |
FlowGram integration, task APIs, trace bridge, starter-side runtime support |
ai4j-flowgram-demo/ |
Demo backend for FlowGram starter integration |
ai4j-bom/ |
Version alignment BOM |
docs-site/ |
Docusaurus documentation site |
ai4j-flowgram-webapp-demo/ |
Web demo frontend surface |
Harness Anything
- Use
ha(Harness Anything) for all new project-management work. harness/is the active private HA ledger with its own nested Git repository..harness/is generated projection/cache state. Neither belongs in code PRs; commit ledger changes insideharness/separately when they must be retained.- Before substantive work, treat
ha capabilities --jsonand the relevantha <domain> --helpoutput as the command authority. If this workspace is not initialized, runha init --repo-id ai4j-sdk --person-id <person-id> --display-name "<display-name>"; then inspectha daemon status,ha agenda,ha agent list --json,ha squad list --json, andha runtime instance list. - The current thin CLI does not expose the historical
ha doctor --json,ha status --json, orha check --profile target-project --strict --jsonpreflight commands. Do not copy those commands from older task records; use the live capabilities/help output instead. - HA writes require explicit actor attribution. Agents use
HARNESS_ACTOR=agent:<id>or an explicit agent actor; humans useha --actor human:<id>. Do not export a human actor for child processes. ConfigureHARNESS_GIT_AUTHOR_NAMEandHARNESS_GIT_AUTHOR_EMAILfor local ledger commits. - The normal write path is the daemon-backed CLI.
HARNESS_DAEMON_MODE=directis only for bootstrap, recovery, or isolated tests, and must carryHARNESS_DIRECT_WRITE_REASON=recovery|test. - Fable identities are installed from packages containing
agent.jsonorsquad.json: validate withha agent validate --source <dir>orha squad validate --source <dir>, install withha agent install --source <dir>orha squad install --source <dir>, then read back withha agent list --jsonplusha agent inspect <id>orha squad list --jsonplusha squad inspect <id>. Dispatch uses a declared identity plus a ready runtime instance; the instance is an execution resource, not the agent or squad identity. - Complete work through the current HA lifecycle: acquire an Execution lease, record progress/evidence, obtain a typed human review/consent when required, and run
ha task complete.ha task reviewis legacy compatibility lint, not the approval gate.
Hard Rules
- Treat repository guidance as monorepo guidance. Do not plan or review work as if this were only
ai4j/plus one starter. - Keep Java modules compatible with Java 8 unless a task explicitly upgrades the baseline.
- Never hardcode secrets, provider keys, or local machine paths intended only for one developer. Use env vars or local config.
- All non-trivial work must use the HA flow: a task under
harness/tasks/, task-local progress/facts/evidence, targeted regression, typed review, andha task complete. - When a change adds or alters a fixed regression surface, update both
docs/05-TEST-QA/Regression-SSoT.mdanddocs/05-TEST-QA/Cadence-Ledger.md. - Do not add new planning, progress, review, or walkthrough files under repo root, legacy
docs/plans/docs/tasks,docs/09-PLANNING/, ordocs/10-WALKTHROUGH/. New task work belongs under the privateharness/tasks/ledger; existing numbered docs remain tracked regression/history surfaces only. - Preserve module boundaries. Core behavior belongs in SDK/runtime modules; starters wire configuration; demos and docs must not become the source of truth for production logic.
- A feature is not considered closed until verification is recorded in the HA task and
ha task complete <id>succeeds.
Repository Structure
Production Code
ai4j/src/main/javaai4j-extension-api/src/main/javaai4j-plugin-ask-user/src/main/javaai4j-agent/src/main/javaai4j-coding/src/main/javaai4j-cli/src/main/javaai4j-spring-boot-starter/src/main/javaai4j-flowgram-spring-boot-starter/src/main/javaai4j-flowgram-demo/src/main/java
Tests
- Java tests live under each module's
src/test/java - Test framework is primarily JUnit 4
- Some suites are pure local tests; others touch live-provider or integration behavior
Existing Documentation
docs/05-TEST-QA/Regression-SSoT.mdanddocs/05-TEST-QA/Cadence-Ledger.mdremain tracked regression governance and are updated when a fixed gate changes.docs/11-REFERENCE/harness-anything-standard.mdis the tracked maintainer reference for the active HA boundary.- Legacy historical docs remain under:
docs/plans/docs/tasks/docs/archive/
AGENT.mdis an architecture note for the agent module, not the repo-wide harness charter
Build And Test Commands
Maven
- Full package:
mvn -DskipTests package - Build one module with dependencies:
mvn -pl <module> -am -DskipTests package - Test one module:
mvn -pl <module> -DskipTests=false test - Test one class:
mvn -pl <module> -Dtest=<ClassName> -DskipTests=false test
Common Modules
- Core SDK:
mvn -pl ai4j -DskipTests=false test - Extension API:
mvn -pl ai4j-extension-api -DskipTests=false test - Ask User plugin:
mvn -pl ai4j-plugin-ask-user -am -DskipTests=false test - Agent runtime:
mvn -pl ai4j-agent -DskipTests=false test - Coding runtime:
mvn -pl ai4j-coding -DskipTests=false test - CLI host:
mvn -pl ai4j-cli -DskipTests=false test - Spring Boot starter:
mvn -pl ai4j-spring-boot-starter -DskipTests=false test - FlowGram starter:
mvn -pl ai4j-flowgram-spring-boot-starter -DskipTests=false test
Frontend And Docs Surfaces
docs-site/: prefernpm run buildwhen docs-site content or config changesai4j-flowgram-webapp-demo/: run the module-local frontend build/test command when this surface changes
Coding Style And Constraints
- Java: 4-space indentation, PascalCase classes, lowerCamelCase methods/fields, UPPER_SNAKE_CASE constants
- Keep packages under
io.github.lnyocly.ai4j - Match surrounding style; do not do mechanical repo-wide reformatting
- Favor targeted edits over wide churn across modules
Testing Notes
- JUnit dependency baseline is
junit:junit:4.13.2 - Many provider-facing tests need external credentials or live endpoints; keep those secrets out of git
- Prefer the smallest regression command that covers the changed surface, then escalate per Cadence Ledger
Branch And Worktree Naming
- Existing branch convention in this repo is:
feature/<name>fix/<name>docs/<name>
- Harness worktrees should mirror repo conventions:
.worktrees/feature/<name>.worktrees/fix/<name>.worktrees/docs/<name>.worktrees/refactor/<name>.worktrees/test/<name>
Task-Type Reading Matrix
| Task type | Read first |
|---|---|
| Extension API / plugin ecosystem contract changes | AGENTS.md, docs/11-REFERENCE/harness-anything-standard.md, and docs/11-REFERENCE/testing-standard.md |
| Official plugin package changes | AGENTS.md, docs/11-REFERENCE/harness-anything-standard.md, and docs/11-REFERENCE/testing-standard.md |
| Core SDK / provider / MCP / RAG / vector / agentflow connector changes | AGENTS.md and docs/11-REFERENCE/harness-anything-standard.md |
| Agent runtime / workflow / trace / subagent changes | AGENTS.md and docs/11-REFERENCE/harness-anything-standard.md |
| Coding runtime / CLI / TUI / ACP changes | AGENTS.md, docs/11-REFERENCE/harness-anything-standard.md, and docs/11-REFERENCE/testing-standard.md |
| Spring Boot / FlowGram starter / demo integration changes | AGENTS.md, docs/11-REFERENCE/harness-anything-standard.md, and docs/11-REFERENCE/testing-standard.md |
| Regression / smoke / verification work | docs/11-REFERENCE/testing-standard.md and docs/05-TEST-QA/Regression-SSoT.md |
| Planning / task tracking / SSoT maintenance | docs/11-REFERENCE/harness-anything-standard.md and AGENTS.md |
| Walkthrough closeout | docs/11-REFERENCE/harness-anything-standard.md and the HA task closeout.md |
| Worktree setup / branch isolation / multi-agent coordination | docs/11-REFERENCE/harness-anything-standard.md, ha capabilities --json, and git worktree --help |
Harness Files
- HA config:
harness/harness.yaml - HA task ledger:
harness/tasks/<task-id>-<slug>/ - HA decisions/facts/context:
harness/decisions/,harness/tasks/*/facts.md, andharness/context/ - HA local projection/cache:
.harness/(rebuildable; never the source of truth) - Historical Feature SSoT:
docs/09-PLANNING/Feature-SSoT.mdremains summary/history only - Regression SSoT:
docs/05-TEST-QA/Regression-SSoT.md - Cadence Ledger:
docs/05-TEST-QA/Cadence-Ledger.md - Maintainer reference:
docs/11-REFERENCE/harness-anything-standard.md
Governance Rule
- New tasks, facts, decisions, relations, reviews, and closeouts use HA under
harness/. - Do not add new
docs/09-PLANNING/TASKS/ordocs/10-WALKTHROUGH/records as a substitute for HA. - Use
ha --helpandha capabilities --jsonas the authoritative current command/schema reference; upstream README examples are orientation only. - Do not hard-delete legacy task directories during migration; archive or supersede them only in a dedicated migration decision/task.
Execution Flow
- Run
ha capabilities --json, inspectha daemon status/ha agenda, and initialize/register the active HA workspace when needed. - Create, pin, and start an HA task before substantive editing: use
ha task create,ha task pin <task-id>, andha task start <task-id>; use the repository-supportedgit worktreeflow when isolation is needed. - Record scope and meaningful progress with
ha task progress append; promote durable observations to Facts and architectural choices to Decisions. - Implement in the narrowest correct module boundary.
- Run targeted regression based on
docs/05-TEST-QA/Cadence-Ledger.mdand record command evidence in the HA task. - Update the tracked Regression SSoT/Cadence Ledger if a fixed gate or evidence scope changes.
- Submit the Execution, obtain typed independent review and owner consent, and run
ha task complete <id>; useha task closeoutwhen a canonical closeout packet is available. - Commit outer code/docs separately from the private
harness/ledger; keep.harness/untracked and rebuildable.
Review Focus
When reviewing changes in this repo, prioritize:
- Cross-module API breakage
- Java 8 or starter compatibility regressions
- Runtime / CLI / FlowGram behavioral regressions
- Missing regression updates for newly touched surfaces
- Drift between code changes and docs/reference guidance
Scope Limits
These bound what you propose, never what you look for. Report anything that is actually wrong here — including a rare-looking case, if this project actually produces it. Then keep the fix in scope.
- This is not a security paper. Verification is welcome; over-defense is not. Unless this project states otherwise, assume a cooperating operator on their own machine; if it has a real adversary, it will say so and that scope wins.
- Do not add hashes, checksums, or fingerprints unless the hash replaces a materially more expensive operation and its result changes what happens next.
- No defensive scaffolding: no feature flags, migration frameworks, compat layers, or wrappers for cases that do not occur here.
- No corner-case obsession: exotic encodings, symlink races, RTL text, and millisecond races are out of scope unless the case is reachable through this project's supported use — its documented inputs, its published interface, its real data. Reachable is enough; you do not need a reproduction. Constructible in principle is not enough.
- Where judgement is needed, judge. Do not replace it with a scoring table, a checklist, or a re-verification loop over something already settled.
- None of this overrides security, migration, verification, or review that the user, this project's own conventions, or a higher-priority rule asked for. Those were requested; they are the work, not scope creep.
Calibration
Shapes already seen. Examples, not a checklist — a real finding is not dismissed by resembling one:
| Shape | |
|---|---|
| H | hashing every row of two spreadsheets to answer what comparing cells answers |
| H | writing checksum files that nothing ever reads |
| E | hardening the accounts of an app that has no users and no deployment |
| R | auditing your own patch all night while the feature stays unwritten |
| R | a reviewer that returns a failing verdict on everything |
| O | guards whose justification is the previous guard, not the requirement |
And two that look like the above and are not. Report these:
| Shape | |
|---|---|
| ✓ | a digest that lets you skip re-reading a large file you already have |
| ✓ | a rare-looking input this project's own documentation example produces |
Before running any check, answer: what specific failure would this detect, and what would I do differently if it occurred? No answer means do not run it.
Say plainly when something is correct. Do not manufacture findings.