@kindgi/cli 0.1.4-rc.5 → 0.1.5-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -10
- package/dist/build/defaults.d.ts +3 -1
- package/dist/build/defaults.d.ts.map +1 -1
- package/dist/build/defaults.js +44 -1
- package/dist/build/defaults.js.map +1 -1
- package/dist/build/java-image.d.ts +31 -0
- package/dist/build/java-image.d.ts.map +1 -0
- package/dist/build/java-image.js +146 -0
- package/dist/build/java-image.js.map +1 -0
- package/dist/build/pack-root.d.ts +1 -31
- package/dist/build/pack-root.d.ts.map +1 -1
- package/dist/build/pack-root.js +22 -2
- package/dist/build/pack-root.js.map +1 -1
- package/dist/build/runners.d.ts +44 -0
- package/dist/build/runners.d.ts.map +1 -1
- package/dist/build/scala-image.d.ts +21 -0
- package/dist/build/scala-image.d.ts.map +1 -0
- package/dist/build/scala-image.js +150 -0
- package/dist/build/scala-image.js.map +1 -0
- package/dist/cli-pin.d.ts +16 -0
- package/dist/cli-pin.d.ts.map +1 -0
- package/dist/cli-pin.js +66 -0
- package/dist/cli-pin.js.map +1 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +9 -8
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/approvals.d.ts.map +1 -1
- package/dist/commands/approvals.js +30 -4
- package/dist/commands/approvals.js.map +1 -1
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +100 -37
- package/dist/commands/artifacts.js.map +1 -1
- package/dist/commands/auth.js +2 -2
- package/dist/commands/blocks.d.ts.map +1 -1
- package/dist/commands/blocks.js +5 -4
- package/dist/commands/blocks.js.map +1 -1
- package/dist/commands/build.d.ts +10 -2
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +109 -16
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/capabilities.d.ts.map +1 -1
- package/dist/commands/capabilities.js +37 -10
- package/dist/commands/capabilities.js.map +1 -1
- package/dist/commands/console.d.ts +21 -0
- package/dist/commands/console.d.ts.map +1 -0
- package/dist/commands/console.js +87 -0
- package/dist/commands/console.js.map +1 -0
- package/dist/commands/conversations.d.ts.map +1 -1
- package/dist/commands/conversations.js +13 -2
- package/dist/commands/conversations.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +2 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +11 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +211 -39
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +18 -5
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +421 -21
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env-scoped.d.ts +44 -0
- package/dist/commands/env-scoped.d.ts.map +1 -0
- package/dist/commands/env-scoped.js +222 -0
- package/dist/commands/env-scoped.js.map +1 -0
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +85 -123
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/eval-runs.d.ts +9 -0
- package/dist/commands/eval-runs.d.ts.map +1 -1
- package/dist/commands/eval-runs.js +20 -19
- package/dist/commands/eval-runs.js.map +1 -1
- package/dist/commands/eval-suites.d.ts.map +1 -1
- package/dist/commands/eval-suites.js +16 -8
- package/dist/commands/eval-suites.js.map +1 -1
- package/dist/commands/exports.d.ts +3 -0
- package/dist/commands/exports.d.ts.map +1 -0
- package/dist/commands/exports.js +82 -0
- package/dist/commands/exports.js.map +1 -0
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +6 -5
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/flows.d.ts.map +1 -1
- package/dist/commands/flows.js +2 -1
- package/dist/commands/flows.js.map +1 -1
- package/dist/commands/gate-policies.d.ts.map +1 -1
- package/dist/commands/gate-policies.js +2 -1
- package/dist/commands/gate-policies.js.map +1 -1
- package/dist/commands/guardrails.d.ts.map +1 -1
- package/dist/commands/guardrails.js +3 -2
- package/dist/commands/guardrails.js.map +1 -1
- package/dist/commands/helpers.js +5 -5
- package/dist/commands/helpers.js.map +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +14 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +254 -18
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/judge-classes.d.ts.map +1 -1
- package/dist/commands/judge-classes.js +11 -10
- package/dist/commands/judge-classes.js.map +1 -1
- package/dist/commands/judgments.d.ts.map +1 -1
- package/dist/commands/judgments.js +7 -6
- package/dist/commands/judgments.js.map +1 -1
- package/dist/commands/key.js +4 -4
- package/dist/commands/memory.d.ts.map +1 -1
- package/dist/commands/memory.js +277 -25
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/people.d.ts +3 -0
- package/dist/commands/people.d.ts.map +1 -0
- package/dist/commands/people.js +166 -0
- package/dist/commands/people.js.map +1 -0
- package/dist/commands/proposals.d.ts.map +1 -1
- package/dist/commands/proposals.js +390 -69
- package/dist/commands/proposals.js.map +1 -1
- package/dist/commands/provenance.d.ts.map +1 -1
- package/dist/commands/provenance.js +6 -7
- package/dist/commands/provenance.js.map +1 -1
- package/dist/commands/providers.d.ts.map +1 -1
- package/dist/commands/providers.js +46 -7
- package/dist/commands/providers.js.map +1 -1
- package/dist/commands/reviewers.d.ts.map +1 -1
- package/dist/commands/reviewers.js +3 -2
- package/dist/commands/reviewers.js.map +1 -1
- package/dist/commands/runs.d.ts.map +1 -1
- package/dist/commands/runs.js +24 -14
- package/dist/commands/runs.js.map +1 -1
- package/dist/commands/schedules.d.ts +3 -0
- package/dist/commands/schedules.d.ts.map +1 -0
- package/dist/commands/schedules.js +275 -0
- package/dist/commands/schedules.js.map +1 -0
- package/dist/commands/secrets.d.ts.map +1 -1
- package/dist/commands/secrets.js +10 -11
- package/dist/commands/secrets.js.map +1 -1
- package/dist/commands/service-accounts.d.ts +3 -0
- package/dist/commands/service-accounts.d.ts.map +1 -0
- package/dist/commands/service-accounts.js +175 -0
- package/dist/commands/service-accounts.js.map +1 -0
- package/dist/commands/skills.d.ts +1 -1
- package/dist/commands/skills.d.ts.map +1 -1
- package/dist/commands/skills.js +11 -4
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/sso.d.ts +6 -0
- package/dist/commands/sso.d.ts.map +1 -0
- package/dist/commands/sso.js +318 -0
- package/dist/commands/sso.js.map +1 -0
- package/dist/commands/tokens.d.ts +11 -0
- package/dist/commands/tokens.d.ts.map +1 -1
- package/dist/commands/tokens.js +144 -11
- package/dist/commands/tokens.js.map +1 -1
- package/dist/commands/tools.d.ts.map +1 -1
- package/dist/commands/tools.js +4 -3
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/unwired.d.ts.map +1 -1
- package/dist/commands/unwired.js +1 -30
- package/dist/commands/unwired.js.map +1 -1
- package/dist/commands/upgrade.d.ts +11 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +160 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/context.d.ts +7 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -0
- package/dist/context.js.map +1 -1
- package/dist/dev/defaults.d.ts +28 -11
- package/dist/dev/defaults.d.ts.map +1 -1
- package/dist/dev/defaults.js +114 -35
- package/dist/dev/defaults.js.map +1 -1
- package/dist/dev/google-credentials.d.ts +50 -0
- package/dist/dev/google-credentials.d.ts.map +1 -0
- package/dist/dev/google-credentials.js +157 -0
- package/dist/dev/google-credentials.js.map +1 -0
- package/dist/dev/java-builder.d.ts +56 -0
- package/dist/dev/java-builder.d.ts.map +1 -0
- package/dist/dev/java-builder.js +204 -0
- package/dist/dev/java-builder.js.map +1 -0
- package/dist/dev/jvm-run-files.d.ts +29 -0
- package/dist/dev/jvm-run-files.d.ts.map +1 -0
- package/dist/dev/jvm-run-files.js +94 -0
- package/dist/dev/jvm-run-files.js.map +1 -0
- package/dist/dev/lines.d.ts +13 -0
- package/dist/dev/lines.d.ts.map +1 -0
- package/dist/dev/lines.js +24 -0
- package/dist/dev/lines.js.map +1 -0
- package/dist/dev/log-view.d.ts +116 -0
- package/dist/dev/log-view.d.ts.map +1 -0
- package/dist/dev/log-view.js +233 -0
- package/dist/dev/log-view.js.map +1 -0
- package/dist/dev/pack-code.d.ts +79 -4
- package/dist/dev/pack-code.d.ts.map +1 -1
- package/dist/dev/pack-code.js +262 -3
- package/dist/dev/pack-code.js.map +1 -1
- package/dist/dev/pack-env.d.ts.map +1 -1
- package/dist/dev/pack-env.js +4 -0
- package/dist/dev/pack-env.js.map +1 -1
- package/dist/dev/pack-service.d.ts +11 -1
- package/dist/dev/pack-service.d.ts.map +1 -1
- package/dist/dev/pack-service.js +56 -20
- package/dist/dev/pack-service.js.map +1 -1
- package/dist/dev/paths.d.ts +6 -0
- package/dist/dev/paths.d.ts.map +1 -1
- package/dist/dev/paths.js +8 -0
- package/dist/dev/paths.js.map +1 -1
- package/dist/dev/project-database.js +1 -1
- package/dist/dev/project-database.js.map +1 -1
- package/dist/dev/runners.d.ts +35 -9
- package/dist/dev/runners.d.ts.map +1 -1
- package/dist/dev/runtime-container.d.ts +10 -2
- package/dist/dev/runtime-container.d.ts.map +1 -1
- package/dist/dev/runtime-container.js +48 -20
- package/dist/dev/runtime-container.js.map +1 -1
- package/dist/dev/runtime-env.d.ts +10 -0
- package/dist/dev/runtime-env.d.ts.map +1 -1
- package/dist/dev/runtime-env.js +8 -4
- package/dist/dev/runtime-env.js.map +1 -1
- package/dist/dev/runtime-image.d.ts +1 -1
- package/dist/dev/runtime-image.js +1 -1
- package/dist/dev/scala-builder.d.ts +72 -0
- package/dist/dev/scala-builder.d.ts.map +1 -0
- package/dist/dev/scala-builder.js +347 -0
- package/dist/dev/scala-builder.js.map +1 -0
- package/dist/env/project-env.d.ts.map +1 -1
- package/dist/env/project-env.js +3 -1
- package/dist/env/project-env.js.map +1 -1
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -1
- package/dist/help.d.ts +14 -0
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +55 -0
- package/dist/help.js.map +1 -1
- package/dist/init/dependency-specs.d.ts +26 -0
- package/dist/init/dependency-specs.d.ts.map +1 -1
- package/dist/init/dependency-specs.js +38 -0
- package/dist/init/dependency-specs.js.map +1 -1
- package/dist/init/java-augment.d.ts +24 -0
- package/dist/init/java-augment.d.ts.map +1 -0
- package/dist/init/java-augment.js +198 -0
- package/dist/init/java-augment.js.map +1 -0
- package/dist/init/mode-detect.d.ts +2 -2
- package/dist/init/mode-detect.d.ts.map +1 -1
- package/dist/init/mode-detect.js +12 -1
- package/dist/init/mode-detect.js.map +1 -1
- package/dist/init/scala-augment.d.ts +23 -0
- package/dist/init/scala-augment.d.ts.map +1 -0
- package/dist/init/scala-augment.js +213 -0
- package/dist/init/scala-augment.js.map +1 -0
- package/dist/init/template-files.d.ts +40 -2
- package/dist/init/template-files.d.ts.map +1 -1
- package/dist/init/template-files.js +56 -5
- package/dist/init/template-files.js.map +1 -1
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +30 -4
- package/dist/main.js.map +1 -1
- package/dist/open-url.d.ts +15 -0
- package/dist/open-url.d.ts.map +1 -0
- package/dist/open-url.js +41 -0
- package/dist/open-url.js.map +1 -0
- package/dist/package-manager.d.ts +10 -3
- package/dist/package-manager.d.ts.map +1 -1
- package/dist/package-manager.js +19 -1
- package/dist/package-manager.js.map +1 -1
- package/dist/providers/preset-loader.d.ts.map +1 -1
- package/dist/providers/preset-loader.js +9 -1
- package/dist/providers/preset-loader.js.map +1 -1
- package/dist/providers/presets/anthropic.json +35 -4
- package/dist/providers/presets/gemini-api.json +3 -0
- package/dist/providers/presets/gemini.json +3 -0
- package/dist/providers/presets/groq.json +1 -0
- package/dist/providers/presets/openai.json +36 -4
- package/dist/providers/presets/openrouter.json +6 -2
- package/dist/sdk-skills/kindgi-authoring-agents/SKILL.md +28 -4
- package/dist/sdk-skills/kindgi-authoring-flows/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-authoring-guardrails/SKILL.md +47 -3
- package/dist/sdk-skills/kindgi-authoring-mcp-servers/SKILL.md +7 -5
- package/dist/sdk-skills/kindgi-authoring-providers/SKILL.md +81 -52
- package/dist/sdk-skills/kindgi-authoring-tools/SKILL.md +27 -1
- package/dist/sdk-skills/kindgi-framework-feedback/SKILL.md +5 -4
- package/dist/sdk-skills/kindgi-getting-started/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-java-authoring-agents/SKILL.md +220 -0
- package/dist/sdk-skills/kindgi-java-authoring-flows/SKILL.md +390 -0
- package/dist/sdk-skills/kindgi-java-authoring-guardrails/SKILL.md +209 -0
- package/dist/sdk-skills/kindgi-java-authoring-tools/SKILL.md +334 -0
- package/dist/sdk-skills/kindgi-java-getting-started/SKILL.md +270 -0
- package/dist/sdk-skills/kindgi-python-authoring-agents/SKILL.md +23 -5
- package/dist/sdk-skills/kindgi-python-authoring-flows/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-python-authoring-guardrails/SKILL.md +10 -3
- package/dist/sdk-skills/kindgi-python-authoring-tools/SKILL.md +36 -5
- package/dist/sdk-skills/kindgi-python-getting-started/SKILL.md +2 -2
- package/dist/sdk-skills/kindgi-scala-authoring-agents/SKILL.md +217 -0
- package/dist/sdk-skills/kindgi-scala-authoring-flows/SKILL.md +357 -0
- package/dist/sdk-skills/kindgi-scala-authoring-guardrails/SKILL.md +199 -0
- package/dist/sdk-skills/kindgi-scala-authoring-tools/SKILL.md +302 -0
- package/dist/sdk-skills/kindgi-scala-getting-started/SKILL.md +302 -0
- package/dist/templates/java/.mvn/wrapper/maven-wrapper.properties +3 -0
- package/dist/templates/java/AGENTS.md +31 -0
- package/dist/templates/java/README.md.tmpl +69 -0
- package/dist/templates/java/gitignore +9 -0
- package/dist/templates/java/kindgi.config.json.tmpl +8 -0
- package/dist/templates/java/kindgiw +33 -0
- package/dist/templates/java/kindgiw.cmd +28 -0
- package/dist/templates/java/mvnw +295 -0
- package/dist/templates/java/pom.xml.tmpl +65 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/agents/EchoAgent.java.tmpl +27 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/flows/EchoFlow.java.tmpl +18 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/guardrails/ResponseNotEmpty.java.tmpl +28 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/tools/Echo.java.tmpl +22 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/tools/Greet.java.tmpl +23 -0
- package/dist/templates/java/src/test/java/__PACKAGE__/ToolsTest.java.tmpl +30 -0
- package/dist/templates/minimal/README.md.tmpl +8 -14
- package/dist/templates/python/README.md.tmpl +6 -6
- package/dist/templates/sample/README.md.tmpl +7 -13
- package/dist/templates/scala/AGENTS.md +32 -0
- package/dist/templates/scala/README.md.tmpl +75 -0
- package/dist/templates/scala/build.sbt.tmpl +16 -0
- package/dist/templates/scala/gitignore +13 -0
- package/dist/templates/scala/kindgi.config.json.tmpl +8 -0
- package/dist/templates/scala/project/build.properties +1 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/agents/EchoAgent.scala.tmpl +23 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/flows/EchoFlow.scala.tmpl +16 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/guardrails/ResponseNotEmpty.scala.tmpl +21 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/tools/Echo.scala.tmpl +16 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/tools/Greet.scala.tmpl +17 -0
- package/dist/templates/scala/src/test/scala/__PACKAGE__/ToolsSuite.scala.tmpl +23 -0
- package/package.json +13 -12
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# {{PACK_NAME}}
|
|
2
|
+
|
|
3
|
+
A sample Kindgi pack in Java — scaffolded by `kindgi init --template=java`.
|
|
4
|
+
|
|
5
|
+
Two tools (`echo`, `greet`), one guardrail (`response-not-empty`), one agent
|
|
6
|
+
that uses both tools and the guardrail, and one flow that runs the echo tool.
|
|
7
|
+
|
|
8
|
+
Java and Scala support is in preview: tested and supported, but the API may
|
|
9
|
+
still change in 0.1.6 without the usual deprecation period.
|
|
10
|
+
|
|
11
|
+
## Layout
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
{{PACK_NAME}}/
|
|
15
|
+
├── kindgi.config.json # the pack's id and version ("language": "java")
|
|
16
|
+
├── pom.xml # com.kindgi:kindgi-pack, Java 17
|
|
17
|
+
├── src/main/java/{{JAVA_PACKAGE_PATH}}/
|
|
18
|
+
│ ├── tools/Echo.java # Tool.define — records in, records out
|
|
19
|
+
│ ├── tools/Greet.java # Tool.define
|
|
20
|
+
│ ├── guardrails/ResponseNotEmpty.java # Guardrail.define — a zero-LLM check over the run
|
|
21
|
+
│ ├── agents/EchoAgent.java # Agent.define — data
|
|
22
|
+
│ └── flows/EchoFlow.java # Flow.define — data
|
|
23
|
+
└── src/test/java/{{JAVA_PACKAGE_PATH}}/ToolsTest.java # the tools, called directly
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Run
|
|
27
|
+
|
|
28
|
+
You need a JDK 17 or later (`JAVA_HOME`); Maven comes with the project
|
|
29
|
+
(`./mvnw`).
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
./mvnw test
|
|
33
|
+
kindgi dev # boots Kindgi locally, compiles and runs this pack, recompiling on save
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then, from another terminal:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
kindgi runs start --agent={{PACK_ID}}.echo-agent --input='{"userMessage":"hi"}'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`kindgi dev` uses `JAVA_HOME`'s JDK (or `dev.javaHome` in `kindgi.config.json`)
|
|
43
|
+
and the project's Maven wrapper (or `dev.maven`, e.g. `["mvn", "-s", "settings.xml"]`).
|
|
44
|
+
`MAVEN_ARGS` and `MAVEN_OPTS` in your shell reach Maven only, never the pack.
|
|
45
|
+
|
|
46
|
+
## Use a real model
|
|
47
|
+
|
|
48
|
+
`kindgi dev` gives a new pack `dev-echo`, a fallback provider that isn't a
|
|
49
|
+
model: it calls the first tool and replies "Tool responded: …", after a
|
|
50
|
+
warning line that says so. It answers only while no other provider fits. To
|
|
51
|
+
use a real model, set one LLM provider's key and register its preset, with
|
|
52
|
+
`kindgi dev` running, from another terminal. For Claude:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
kindgi secrets set ANTHROPIC_API_KEY --env=local --scope=tenant # no-echo prompt; writes .env.local
|
|
56
|
+
kindgi providers register --preset=anthropic # Opus 5.5, Sonnet 5.5, Haiku 4.5
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Claude takes over from dev-echo on the next turn; nothing to restart.
|
|
60
|
+
OpenAI (`OPENAI_API_KEY`, `--preset=openai`), Gemini (`GEMINI_API_KEY`,
|
|
61
|
+
`--preset=gemini-api`), Groq (`GROQ_API_KEY`, `--preset=groq`) and
|
|
62
|
+
OpenRouter (`OPENROUTER_API_KEY`, `--preset=openrouter`) work the same way;
|
|
63
|
+
`kindgi providers presets` lists the presets.
|
|
64
|
+
|
|
65
|
+
## Build
|
|
66
|
+
|
|
67
|
+
`kindgi build --env=<name>` makes the pack's image: Maven compiles it in a
|
|
68
|
+
pinned Maven + JDK 17 image, the index is built in the image, and the pack
|
|
69
|
+
service runs on a JRE 17 as its entrypoint.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# kindgiw: runs the Kindgi CLI this pack pins ("cli" in kindgi.config.json),
|
|
3
|
+
# as mvnw runs the Maven it pins. Written by `kindgi init`; `kindgi upgrade`
|
|
4
|
+
# moves the pin.
|
|
5
|
+
#
|
|
6
|
+
# ./kindgiw dev
|
|
7
|
+
# ./kindgiw runs start --agent=<id> --input='{"userMessage":"hi"}'
|
|
8
|
+
#
|
|
9
|
+
# It runs the CLI from npm (npx) when Node is installed, else from PyPI
|
|
10
|
+
# (uvx; kindgi-cli brings its own Node), else says how to get one of them.
|
|
11
|
+
set -eu
|
|
12
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
13
|
+
config="$dir/kindgi.config.json"
|
|
14
|
+
version=$(sed -n 's/^[[:space:]]*"cli"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$config" 2>/dev/null | head -n 1)
|
|
15
|
+
if [ -z "$version" ]; then
|
|
16
|
+
echo "kindgiw: no \"cli\" version in $config (kindgi upgrade writes it)." >&2
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
if command -v node >/dev/null 2>&1 && command -v npx >/dev/null 2>&1; then
|
|
20
|
+
exec npx --yes "@kindgi/cli@$version" "$@"
|
|
21
|
+
fi
|
|
22
|
+
# PyPI spells pre-releases PEP 440's way: 0.1.6-rc.2 is 0.1.6rc2.
|
|
23
|
+
pep440=$(printf '%s' "$version" | sed -e 's/-alpha\./a/' -e 's/-beta\./b/' -e 's/-rc\./rc/')
|
|
24
|
+
if command -v uvx >/dev/null 2>&1; then
|
|
25
|
+
exec uvx --from "kindgi-cli==$pep440" kindgi "$@"
|
|
26
|
+
fi
|
|
27
|
+
if command -v uv >/dev/null 2>&1; then
|
|
28
|
+
exec uv tool run --from "kindgi-cli==$pep440" kindgi "$@"
|
|
29
|
+
fi
|
|
30
|
+
echo "kindgiw: the Kindgi CLI $version runs with Node 22.12 or later (https://nodejs.org)," >&2
|
|
31
|
+
echo " or with uv (https://docs.astral.sh/uv/getting-started/installation/), which needs no Node." >&2
|
|
32
|
+
echo " Install either one, then run ./kindgiw again." >&2
|
|
33
|
+
exit 1
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
rem kindgiw: runs the Kindgi CLI this pack pins ("cli" in kindgi.config.json),
|
|
3
|
+
rem as mvnw runs the Maven it pins. Written by `kindgi init`; `kindgi upgrade`
|
|
4
|
+
rem moves the pin. From npm (npx) with Node, else from PyPI (uvx).
|
|
5
|
+
setlocal
|
|
6
|
+
set "KINDGIW_DIR=%~dp0"
|
|
7
|
+
set "KINDGIW_VERSION="
|
|
8
|
+
for /f "usebackq delims=" %%v in (`powershell -NoProfile -Command "(Get-Content -Raw -LiteralPath '%KINDGIW_DIR%kindgi.config.json' | ConvertFrom-Json).cli"`) do set "KINDGIW_VERSION=%%v"
|
|
9
|
+
if "%KINDGIW_VERSION%"=="" (
|
|
10
|
+
echo kindgiw: no "cli" version in %KINDGIW_DIR%kindgi.config.json ^(kindgi upgrade writes it^). 1>&2
|
|
11
|
+
exit /b 1
|
|
12
|
+
)
|
|
13
|
+
rem `call`: npx is a batch file, and a batch file run without it never returns.
|
|
14
|
+
where node >nul 2>nul && where npx >nul 2>nul && (
|
|
15
|
+
call npx --yes "@kindgi/cli@%KINDGIW_VERSION%" %*
|
|
16
|
+
exit /b
|
|
17
|
+
)
|
|
18
|
+
set "KINDGIW_PEP440=%KINDGIW_VERSION:-alpha.=a%"
|
|
19
|
+
set "KINDGIW_PEP440=%KINDGIW_PEP440:-beta.=b%"
|
|
20
|
+
set "KINDGIW_PEP440=%KINDGIW_PEP440:-rc.=rc%"
|
|
21
|
+
where uvx >nul 2>nul && (
|
|
22
|
+
call uvx --from "kindgi-cli==%KINDGIW_PEP440%" kindgi %*
|
|
23
|
+
exit /b
|
|
24
|
+
)
|
|
25
|
+
echo kindgiw: the Kindgi CLI %KINDGIW_VERSION% runs with Node 22.12 or later ^(https://nodejs.org^), 1>&2
|
|
26
|
+
echo or with uv ^(https://docs.astral.sh/uv/getting-started/installation/^), which needs no Node. 1>&2
|
|
27
|
+
echo Install either one, then run kindgiw again. 1>&2
|
|
28
|
+
exit /b 1
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ----------------------------------------------------------------------------
|
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
# ----------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
# ----------------------------------------------------------------------------
|
|
22
|
+
# Apache Maven Wrapper startup batch script, version 3.3.4
|
|
23
|
+
#
|
|
24
|
+
# Optional ENV vars
|
|
25
|
+
# -----------------
|
|
26
|
+
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
|
27
|
+
# MVNW_REPOURL - repo url base for downloading maven distribution
|
|
28
|
+
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
|
29
|
+
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
|
30
|
+
# ----------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
set -euf
|
|
33
|
+
[ "${MVNW_VERBOSE-}" != debug ] || set -x
|
|
34
|
+
|
|
35
|
+
# OS specific support.
|
|
36
|
+
native_path() { printf %s\\n "$1"; }
|
|
37
|
+
case "$(uname)" in
|
|
38
|
+
CYGWIN* | MINGW*)
|
|
39
|
+
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
|
|
40
|
+
native_path() { cygpath --path --windows "$1"; }
|
|
41
|
+
;;
|
|
42
|
+
esac
|
|
43
|
+
|
|
44
|
+
# set JAVACMD and JAVACCMD
|
|
45
|
+
set_java_home() {
|
|
46
|
+
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
|
|
47
|
+
if [ -n "${JAVA_HOME-}" ]; then
|
|
48
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
|
|
49
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
|
50
|
+
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
51
|
+
JAVACCMD="$JAVA_HOME/jre/sh/javac"
|
|
52
|
+
else
|
|
53
|
+
JAVACMD="$JAVA_HOME/bin/java"
|
|
54
|
+
JAVACCMD="$JAVA_HOME/bin/javac"
|
|
55
|
+
|
|
56
|
+
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
|
|
57
|
+
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
|
|
58
|
+
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
|
|
59
|
+
return 1
|
|
60
|
+
fi
|
|
61
|
+
fi
|
|
62
|
+
else
|
|
63
|
+
JAVACMD="$(
|
|
64
|
+
'set' +e
|
|
65
|
+
'unset' -f command 2>/dev/null
|
|
66
|
+
'command' -v java
|
|
67
|
+
)" || :
|
|
68
|
+
JAVACCMD="$(
|
|
69
|
+
'set' +e
|
|
70
|
+
'unset' -f command 2>/dev/null
|
|
71
|
+
'command' -v javac
|
|
72
|
+
)" || :
|
|
73
|
+
|
|
74
|
+
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
|
|
75
|
+
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
|
|
76
|
+
return 1
|
|
77
|
+
fi
|
|
78
|
+
fi
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# hash string like Java String::hashCode
|
|
82
|
+
hash_string() {
|
|
83
|
+
str="${1:-}" h=0
|
|
84
|
+
while [ -n "$str" ]; do
|
|
85
|
+
char="${str%"${str#?}"}"
|
|
86
|
+
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
|
|
87
|
+
str="${str#?}"
|
|
88
|
+
done
|
|
89
|
+
printf %x\\n $h
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
verbose() { :; }
|
|
93
|
+
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
|
|
94
|
+
|
|
95
|
+
die() {
|
|
96
|
+
printf %s\\n "$1" >&2
|
|
97
|
+
exit 1
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
trim() {
|
|
101
|
+
# MWRAPPER-139:
|
|
102
|
+
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
|
|
103
|
+
# Needed for removing poorly interpreted newline sequences when running in more
|
|
104
|
+
# exotic environments such as mingw bash on Windows.
|
|
105
|
+
printf "%s" "${1}" | tr -d '[:space:]'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
scriptDir="$(dirname "$0")"
|
|
109
|
+
scriptName="$(basename "$0")"
|
|
110
|
+
|
|
111
|
+
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
|
|
112
|
+
while IFS="=" read -r key value; do
|
|
113
|
+
case "${key-}" in
|
|
114
|
+
distributionUrl) distributionUrl=$(trim "${value-}") ;;
|
|
115
|
+
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
|
|
116
|
+
esac
|
|
117
|
+
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
|
118
|
+
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
|
119
|
+
|
|
120
|
+
case "${distributionUrl##*/}" in
|
|
121
|
+
maven-mvnd-*bin.*)
|
|
122
|
+
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
|
|
123
|
+
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
|
|
124
|
+
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
|
|
125
|
+
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
|
|
126
|
+
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
|
|
127
|
+
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
|
|
128
|
+
*)
|
|
129
|
+
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
|
|
130
|
+
distributionPlatform=linux-amd64
|
|
131
|
+
;;
|
|
132
|
+
esac
|
|
133
|
+
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
|
|
134
|
+
;;
|
|
135
|
+
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
|
136
|
+
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
|
137
|
+
esac
|
|
138
|
+
|
|
139
|
+
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
|
140
|
+
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
|
141
|
+
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
|
142
|
+
distributionUrlName="${distributionUrl##*/}"
|
|
143
|
+
distributionUrlNameMain="${distributionUrlName%.*}"
|
|
144
|
+
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
|
|
145
|
+
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
|
|
146
|
+
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
|
|
147
|
+
|
|
148
|
+
exec_maven() {
|
|
149
|
+
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
|
|
150
|
+
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if [ -d "$MAVEN_HOME" ]; then
|
|
154
|
+
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
|
155
|
+
exec_maven "$@"
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
case "${distributionUrl-}" in
|
|
159
|
+
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
|
|
160
|
+
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
|
|
161
|
+
esac
|
|
162
|
+
|
|
163
|
+
# prepare tmp dir
|
|
164
|
+
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
|
|
165
|
+
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
|
|
166
|
+
trap clean HUP INT TERM EXIT
|
|
167
|
+
else
|
|
168
|
+
die "cannot create temp dir"
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
mkdir -p -- "${MAVEN_HOME%/*}"
|
|
172
|
+
|
|
173
|
+
# Download and Install Apache Maven
|
|
174
|
+
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
|
175
|
+
verbose "Downloading from: $distributionUrl"
|
|
176
|
+
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
|
177
|
+
|
|
178
|
+
# select .zip or .tar.gz
|
|
179
|
+
if ! command -v unzip >/dev/null; then
|
|
180
|
+
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
|
181
|
+
distributionUrlName="${distributionUrl##*/}"
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
# verbose opt
|
|
185
|
+
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
|
|
186
|
+
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
|
|
187
|
+
|
|
188
|
+
# normalize http auth
|
|
189
|
+
case "${MVNW_PASSWORD:+has-password}" in
|
|
190
|
+
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
|
191
|
+
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
|
192
|
+
esac
|
|
193
|
+
|
|
194
|
+
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
|
|
195
|
+
verbose "Found wget ... using wget"
|
|
196
|
+
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
|
|
197
|
+
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
|
|
198
|
+
verbose "Found curl ... using curl"
|
|
199
|
+
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
|
|
200
|
+
elif set_java_home; then
|
|
201
|
+
verbose "Falling back to use Java to download"
|
|
202
|
+
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
|
|
203
|
+
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
|
|
204
|
+
cat >"$javaSource" <<-END
|
|
205
|
+
public class Downloader extends java.net.Authenticator
|
|
206
|
+
{
|
|
207
|
+
protected java.net.PasswordAuthentication getPasswordAuthentication()
|
|
208
|
+
{
|
|
209
|
+
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
|
|
210
|
+
}
|
|
211
|
+
public static void main( String[] args ) throws Exception
|
|
212
|
+
{
|
|
213
|
+
setDefault( new Downloader() );
|
|
214
|
+
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
END
|
|
218
|
+
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
|
|
219
|
+
verbose " - Compiling Downloader.java ..."
|
|
220
|
+
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
|
|
221
|
+
verbose " - Running Downloader.java ..."
|
|
222
|
+
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
|
226
|
+
if [ -n "${distributionSha256Sum-}" ]; then
|
|
227
|
+
distributionSha256Result=false
|
|
228
|
+
if [ "$MVN_CMD" = mvnd.sh ]; then
|
|
229
|
+
echo "Checksum validation is not supported for maven-mvnd." >&2
|
|
230
|
+
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
|
231
|
+
exit 1
|
|
232
|
+
elif command -v sha256sum >/dev/null; then
|
|
233
|
+
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
|
|
234
|
+
distributionSha256Result=true
|
|
235
|
+
fi
|
|
236
|
+
elif command -v shasum >/dev/null; then
|
|
237
|
+
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
|
|
238
|
+
distributionSha256Result=true
|
|
239
|
+
fi
|
|
240
|
+
else
|
|
241
|
+
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
|
|
242
|
+
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
|
243
|
+
exit 1
|
|
244
|
+
fi
|
|
245
|
+
if [ $distributionSha256Result = false ]; then
|
|
246
|
+
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
|
|
247
|
+
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
|
|
248
|
+
exit 1
|
|
249
|
+
fi
|
|
250
|
+
fi
|
|
251
|
+
|
|
252
|
+
# unzip and move
|
|
253
|
+
if command -v unzip >/dev/null; then
|
|
254
|
+
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
|
|
255
|
+
else
|
|
256
|
+
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
|
|
257
|
+
fi
|
|
258
|
+
|
|
259
|
+
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
|
260
|
+
actualDistributionDir=""
|
|
261
|
+
|
|
262
|
+
# First try the expected directory name (for regular distributions)
|
|
263
|
+
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
|
|
264
|
+
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
|
|
265
|
+
actualDistributionDir="$distributionUrlNameMain"
|
|
266
|
+
fi
|
|
267
|
+
fi
|
|
268
|
+
|
|
269
|
+
# If not found, search for any directory with the Maven executable (for snapshots)
|
|
270
|
+
if [ -z "$actualDistributionDir" ]; then
|
|
271
|
+
# enable globbing to iterate over items
|
|
272
|
+
set +f
|
|
273
|
+
for dir in "$TMP_DOWNLOAD_DIR"/*; do
|
|
274
|
+
if [ -d "$dir" ]; then
|
|
275
|
+
if [ -f "$dir/bin/$MVN_CMD" ]; then
|
|
276
|
+
actualDistributionDir="$(basename "$dir")"
|
|
277
|
+
break
|
|
278
|
+
fi
|
|
279
|
+
fi
|
|
280
|
+
done
|
|
281
|
+
set -f
|
|
282
|
+
fi
|
|
283
|
+
|
|
284
|
+
if [ -z "$actualDistributionDir" ]; then
|
|
285
|
+
verbose "Contents of $TMP_DOWNLOAD_DIR:"
|
|
286
|
+
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
|
|
287
|
+
die "Could not find Maven distribution directory in extracted archive"
|
|
288
|
+
fi
|
|
289
|
+
|
|
290
|
+
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
|
291
|
+
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
|
|
292
|
+
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
|
293
|
+
|
|
294
|
+
clean || :
|
|
295
|
+
exec_maven "$@"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
5
|
+
<modelVersion>4.0.0</modelVersion>
|
|
6
|
+
|
|
7
|
+
<groupId>{{JAVA_PACKAGE}}</groupId>
|
|
8
|
+
<artifactId>{{PACK_NAME}}</artifactId>
|
|
9
|
+
<version>{{PACK_VERSION}}</version>
|
|
10
|
+
<name>{{PACK_NAME}}</name>
|
|
11
|
+
<description>A Kindgi pack in Java: its tools, guardrail checks, agents and flows.</description>
|
|
12
|
+
|
|
13
|
+
<properties>
|
|
14
|
+
<maven.compiler.release>17</maven.compiler.release>
|
|
15
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
16
|
+
<kindgi.version>{{KINDGI_JAVA_VERSION}}</kindgi.version>
|
|
17
|
+
</properties>
|
|
18
|
+
|
|
19
|
+
<dependencies>
|
|
20
|
+
<!-- Tools, guardrail checks, the indexer and the pack service. -->
|
|
21
|
+
<dependency>
|
|
22
|
+
<groupId>com.kindgi</groupId>
|
|
23
|
+
<artifactId>kindgi-pack</artifactId>
|
|
24
|
+
<version>${kindgi.version}</version>
|
|
25
|
+
</dependency>
|
|
26
|
+
<!-- Constraints on tool inputs (@Size, @Min, @Email, …) become their schemas' keywords. -->
|
|
27
|
+
<dependency>
|
|
28
|
+
<groupId>jakarta.validation</groupId>
|
|
29
|
+
<artifactId>jakarta.validation-api</artifactId>
|
|
30
|
+
<version>3.0.2</version>
|
|
31
|
+
</dependency>
|
|
32
|
+
|
|
33
|
+
<dependency>
|
|
34
|
+
<groupId>org.junit.jupiter</groupId>
|
|
35
|
+
<artifactId>junit-jupiter</artifactId>
|
|
36
|
+
<version>6.1.3</version>
|
|
37
|
+
<scope>test</scope>
|
|
38
|
+
</dependency>
|
|
39
|
+
</dependencies>
|
|
40
|
+
|
|
41
|
+
<build>
|
|
42
|
+
<plugins>
|
|
43
|
+
<plugin>
|
|
44
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
45
|
+
<artifactId>maven-resources-plugin</artifactId>
|
|
46
|
+
<version>3.5.0</version>
|
|
47
|
+
</plugin>
|
|
48
|
+
<plugin>
|
|
49
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
50
|
+
<artifactId>maven-compiler-plugin</artifactId>
|
|
51
|
+
<version>3.16.0</version>
|
|
52
|
+
</plugin>
|
|
53
|
+
<plugin>
|
|
54
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
55
|
+
<artifactId>maven-surefire-plugin</artifactId>
|
|
56
|
+
<version>3.6.0</version>
|
|
57
|
+
</plugin>
|
|
58
|
+
<plugin>
|
|
59
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
60
|
+
<artifactId>maven-dependency-plugin</artifactId>
|
|
61
|
+
<version>3.11.0</version>
|
|
62
|
+
</plugin>
|
|
63
|
+
</plugins>
|
|
64
|
+
</build>
|
|
65
|
+
</project>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package {{JAVA_PACKAGE}}.agents;
|
|
2
|
+
|
|
3
|
+
import {{JAVA_PACKAGE}}.guardrails.ResponseNotEmpty;
|
|
4
|
+
import {{JAVA_PACKAGE}}.tools.Echo;
|
|
5
|
+
import {{JAVA_PACKAGE}}.tools.Greet;
|
|
6
|
+
import com.kindgi.pack.Agent;
|
|
7
|
+
import java.util.List;
|
|
8
|
+
import java.util.Map;
|
|
9
|
+
|
|
10
|
+
/** {{PACK_ID}}.echo-agent — uses both tools; the response-not-empty guardrail guards its answer. */
|
|
11
|
+
public final class EchoAgent {
|
|
12
|
+
public static final Agent AGENT = Agent.define("{{PACK_ID}}.echo-agent")
|
|
13
|
+
.version("{{PACK_VERSION}}")
|
|
14
|
+
.name("Echo Agent")
|
|
15
|
+
.description("Uses the pack's echo and greet tools; the response-not-empty guardrail guards the output.")
|
|
16
|
+
.instructions("For each user message: if the user sends a name, greet them with the greet tool. "
|
|
17
|
+
+ "Otherwise echo their message with the echo tool. Quote the tool result verbatim.")
|
|
18
|
+
.capability(Map.of("needs", List.of(Map.of("feature", "tool-use"))))
|
|
19
|
+
.tool(Echo.TOOL)
|
|
20
|
+
.tool(Greet.TOOL)
|
|
21
|
+
.guardrail(ResponseNotEmpty.GUARDRAIL)
|
|
22
|
+
.set("conversationPolicy", Map.of("historyLimit", 10))
|
|
23
|
+
.set("budget", Map.of("maxSteps", 4, "maxCostUsd", 0.1, "maxWallMs", 60_000))
|
|
24
|
+
.build();
|
|
25
|
+
|
|
26
|
+
private EchoAgent() {}
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package {{JAVA_PACKAGE}}.flows;
|
|
2
|
+
|
|
3
|
+
import {{JAVA_PACKAGE}}.tools.Echo;
|
|
4
|
+
import com.kindgi.pack.Flow;
|
|
5
|
+
|
|
6
|
+
/** {{PACK_ID}}.echo-flow — runs the pack's echo tool, then ends. */
|
|
7
|
+
public final class EchoFlow {
|
|
8
|
+
public static final Flow FLOW = Flow.define("{{PACK_ID}}.echo-flow")
|
|
9
|
+
.version("{{PACK_VERSION}}")
|
|
10
|
+
.set("name", "Echo Flow")
|
|
11
|
+
.set("description", "Runs the pack's echo tool and terminates.")
|
|
12
|
+
.toolNode("echo", Echo.TOOL)
|
|
13
|
+
.edge("e-start", "$start", "echo")
|
|
14
|
+
.edge("e-end", "echo", "$end")
|
|
15
|
+
.build();
|
|
16
|
+
|
|
17
|
+
private EchoFlow() {}
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package {{JAVA_PACKAGE}}.guardrails;
|
|
2
|
+
|
|
3
|
+
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
4
|
+
import com.kindgi.pack.CheckResult;
|
|
5
|
+
import com.kindgi.pack.Guardrail;
|
|
6
|
+
import jakarta.validation.constraints.Min;
|
|
7
|
+
import java.util.Map;
|
|
8
|
+
|
|
9
|
+
/** {{PACK_ID}}.response-not-empty — a zero-LLM guardrail: the run's answer has content. */
|
|
10
|
+
public final class ResponseNotEmpty {
|
|
11
|
+
public record Config(@JsonProperty(defaultValue = "1") @Min(0) int minLength) {}
|
|
12
|
+
|
|
13
|
+
public static final Guardrail<Config> GUARDRAIL = Guardrail.define("{{PACK_ID}}.response-not-empty")
|
|
14
|
+
.name("Response is non-empty")
|
|
15
|
+
.checkId("{{PACK_ID}}.checks.response-not-empty")
|
|
16
|
+
.onViolation("halt")
|
|
17
|
+
.severity("error")
|
|
18
|
+
.set("scope", Map.of("when", "runtime-only"))
|
|
19
|
+
.config(Config.class)
|
|
20
|
+
.check((config, trace) -> {
|
|
21
|
+
String text = trace.output() == null ? "" : trace.output().strip();
|
|
22
|
+
return text.length() >= config.minLength()
|
|
23
|
+
? CheckResult.pass()
|
|
24
|
+
: CheckResult.fail("Response too short: " + text.length() + " chars, expected >= " + config.minLength() + ".");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
private ResponseNotEmpty() {}
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package {{JAVA_PACKAGE}}.tools;
|
|
2
|
+
|
|
3
|
+
import com.kindgi.pack.Tool;
|
|
4
|
+
import jakarta.validation.constraints.PositiveOrZero;
|
|
5
|
+
import jakarta.validation.constraints.Size;
|
|
6
|
+
import java.time.Instant;
|
|
7
|
+
|
|
8
|
+
/** {{PACK_ID}}.echo — echoes the message back with a UTC timestamp and its length. */
|
|
9
|
+
public final class Echo {
|
|
10
|
+
public record Input(@Size(min = 1, max = 500) String message) {}
|
|
11
|
+
|
|
12
|
+
public record Output(String echo, Instant echoedAt, @PositiveOrZero int characterCount) {}
|
|
13
|
+
|
|
14
|
+
public static final Tool<Input, Output> TOOL = Tool.define("{{PACK_ID}}.echo")
|
|
15
|
+
.description("Echoes the caller-provided message with a UTC timestamp and character count.")
|
|
16
|
+
.input(Input.class)
|
|
17
|
+
.output(Output.class)
|
|
18
|
+
.mutating(false)
|
|
19
|
+
.handler((input, ctx) -> new Output(input.message(), Instant.now(), input.message().length()));
|
|
20
|
+
|
|
21
|
+
private Echo() {}
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package {{JAVA_PACKAGE}}.tools;
|
|
2
|
+
|
|
3
|
+
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
4
|
+
import com.kindgi.pack.Tool;
|
|
5
|
+
import jakarta.validation.constraints.Size;
|
|
6
|
+
|
|
7
|
+
/** {{PACK_ID}}.greet — greets a named recipient. */
|
|
8
|
+
public final class Greet {
|
|
9
|
+
public record Input(
|
|
10
|
+
@Size(min = 1, max = 100) String name,
|
|
11
|
+
@JsonProperty(defaultValue = "Hello") @Size(min = 1, max = 50) String greeting) {}
|
|
12
|
+
|
|
13
|
+
public record Output(String message) {}
|
|
14
|
+
|
|
15
|
+
public static final Tool<Input, Output> TOOL = Tool.define("{{PACK_ID}}.greet")
|
|
16
|
+
.description("Formats a greeting for the named recipient.")
|
|
17
|
+
.input(Input.class)
|
|
18
|
+
.output(Output.class)
|
|
19
|
+
.mutating(false)
|
|
20
|
+
.handler((input, ctx) -> new Output(input.greeting() + ", " + input.name() + "!"));
|
|
21
|
+
|
|
22
|
+
private Greet() {}
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package {{JAVA_PACKAGE}};
|
|
2
|
+
|
|
3
|
+
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
4
|
+
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
5
|
+
|
|
6
|
+
import {{JAVA_PACKAGE}}.tools.Echo;
|
|
7
|
+
import {{JAVA_PACKAGE}}.tools.Greet;
|
|
8
|
+
import com.kindgi.pack.ToolContext;
|
|
9
|
+
import org.junit.jupiter.api.Test;
|
|
10
|
+
|
|
11
|
+
/** The pack's tools, called directly — `./mvnw test`. */
|
|
12
|
+
class ToolsTest {
|
|
13
|
+
@Test
|
|
14
|
+
void echoRoundTripsTheMessage() throws Exception {
|
|
15
|
+
Echo.Output out = Echo.TOOL.call(new Echo.Input("hello"), ToolContext.forTest());
|
|
16
|
+
assertEquals("hello", out.echo());
|
|
17
|
+
assertEquals(5, out.characterCount());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Test
|
|
21
|
+
void greetUsesTheGreetingItIsGiven() throws Exception {
|
|
22
|
+
assertEquals("Hi, Ada!", Greet.TOOL.call(new Greet.Input("Ada", "Hi"), ToolContext.forTest()).message());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Test
|
|
26
|
+
void theToolsSayTheyOnlyRead() {
|
|
27
|
+
assertFalse(Echo.TOOL.mutating());
|
|
28
|
+
assertFalse(Greet.TOOL.mutating());
|
|
29
|
+
}
|
|
30
|
+
}
|