@arki/dot 0.1.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/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/cli/discover.d.ts +65 -0
- package/dist/cli/discover.d.ts.map +1 -0
- package/dist/cli/discover.js +184 -0
- package/dist/cli/discover.js.map +1 -0
- package/dist/cli/error-codes.d.ts +49 -0
- package/dist/cli/error-codes.d.ts.map +1 -0
- package/dist/cli/error-codes.js +61 -0
- package/dist/cli/error-codes.js.map +1 -0
- package/dist/cli/files.d.ts +67 -0
- package/dist/cli/files.d.ts.map +1 -0
- package/dist/cli/files.js +80 -0
- package/dist/cli/files.js.map +1 -0
- package/dist/cli/index.d.ts +95 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +456 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/json.d.ts +38 -0
- package/dist/cli/json.d.ts.map +1 -0
- package/dist/cli/json.js +18 -0
- package/dist/cli/json.js.map +1 -0
- package/dist/cli/new.d.ts +105 -0
- package/dist/cli/new.d.ts.map +1 -0
- package/dist/cli/new.js +322 -0
- package/dist/cli/new.js.map +1 -0
- package/dist/cli/observability-probe.d.ts +28 -0
- package/dist/cli/observability-probe.d.ts.map +1 -0
- package/dist/cli/observability-probe.js +44 -0
- package/dist/cli/observability-probe.js.map +1 -0
- package/dist/cli/render-doctor.d.ts +26 -0
- package/dist/cli/render-doctor.d.ts.map +1 -0
- package/dist/cli/render-doctor.js +183 -0
- package/dist/cli/render-doctor.js.map +1 -0
- package/dist/cli/render-explain.d.ts +43 -0
- package/dist/cli/render-explain.d.ts.map +1 -0
- package/dist/cli/render-explain.js +127 -0
- package/dist/cli/render-explain.js.map +1 -0
- package/dist/define-app.d.ts +125 -0
- package/dist/define-app.d.ts.map +1 -0
- package/dist/define-app.js +126 -0
- package/dist/define-app.js.map +1 -0
- package/dist/dependency-graph.d.ts +25 -0
- package/dist/dependency-graph.d.ts.map +1 -0
- package/dist/dependency-graph.js +86 -0
- package/dist/dependency-graph.js.map +1 -0
- package/dist/diagnostics.d.ts +83 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +14 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel/app-instance.d.ts +62 -0
- package/dist/kernel/app-instance.d.ts.map +1 -0
- package/dist/kernel/app-instance.js +1040 -0
- package/dist/kernel/app-instance.js.map +1 -0
- package/dist/kernel/otel.d.ts +105 -0
- package/dist/kernel/otel.d.ts.map +1 -0
- package/dist/kernel/otel.js +218 -0
- package/dist/kernel/otel.js.map +1 -0
- package/dist/lifecycle-observer.d.ts +95 -0
- package/dist/lifecycle-observer.d.ts.map +1 -0
- package/dist/lifecycle-observer.js +19 -0
- package/dist/lifecycle-observer.js.map +1 -0
- package/dist/lifecycle.d.ts +94 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +78 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/manifest.d.ts +75 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +14 -0
- package/dist/manifest.js.map +1 -0
- package/dist/pip-contract.d.ts +219 -0
- package/dist/pip-contract.d.ts.map +1 -0
- package/dist/pip-contract.js +90 -0
- package/dist/pip-contract.js.map +1 -0
- package/dist/pip.d.ts +33 -0
- package/dist/pip.d.ts.map +1 -0
- package/dist/pip.js +25 -0
- package/dist/pip.js.map +1 -0
- package/dist/plugin-contract.d.ts +175 -0
- package/dist/plugin-contract.d.ts.map +1 -0
- package/dist/plugin-contract.js +45 -0
- package/dist/plugin-contract.js.map +1 -0
- package/dist/plugin.d.ts +30 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +24 -0
- package/dist/plugin.js.map +1 -0
- package/dist/test-harness.d.ts +42 -0
- package/dist/test-harness.d.ts.map +1 -0
- package/dist/test-harness.js +46 -0
- package/dist/test-harness.js.map +1 -0
- package/dist/timeline.d.ts +43 -0
- package/dist/timeline.d.ts.map +1 -0
- package/dist/timeline.js +121 -0
- package/dist/timeline.js.map +1 -0
- package/package.json +68 -0
- package/templates/app-minimal/.gitignore.tmpl +6 -0
- package/templates/app-minimal/AGENTS.md.tmpl +66 -0
- package/templates/app-minimal/README.md.tmpl +24 -0
- package/templates/app-minimal/package.json.tmpl +21 -0
- package/templates/app-minimal/src/app.ts.tmpl +20 -0
- package/templates/app-minimal/src/env.ts.tmpl +12 -0
- package/templates/app-minimal/tests/boot.test.ts.tmpl +25 -0
- package/templates/app-minimal/tsconfig.json.tmpl +22 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Agent Guidance — {{name}}
|
|
2
|
+
|
|
3
|
+
## What this app is
|
|
4
|
+
|
|
5
|
+
A DOT app composed via `defineApp(...).use(pip).boot()`. The runtime
|
|
6
|
+
graph is statically inspectable via `app.manifest` and runtime-inspectable
|
|
7
|
+
via `app.diagnostics`.
|
|
8
|
+
|
|
9
|
+
## Verification commands
|
|
10
|
+
|
|
11
|
+
After any change, run these in order:
|
|
12
|
+
|
|
13
|
+
1. `{{pkgManager}} run typecheck` — TypeScript compilation must pass.
|
|
14
|
+
2. `{{pkgManager}} run test` — vitest must pass (booting the app and
|
|
15
|
+
asserting manifest shape).
|
|
16
|
+
3. `bunx dot explain --json` — inspect the static graph.
|
|
17
|
+
4. `bunx dot doctor --json` — verify runtime health (5-array diagnostics
|
|
18
|
+
plus issues).
|
|
19
|
+
|
|
20
|
+
Stop and surface any failure. Don't claim "done" until every verification
|
|
21
|
+
command exits zero.
|
|
22
|
+
|
|
23
|
+
## Local conventions
|
|
24
|
+
|
|
25
|
+
- App entrypoint lives at `src/app.ts` and exports the booted `app`.
|
|
26
|
+
- Env schema lives at `src/env.ts` — keep it narrow; one entry per env
|
|
27
|
+
key the app actually reads.
|
|
28
|
+
- Tests live under `tests/` and import the app via the `src/` barrel.
|
|
29
|
+
- Add new pips by wiring `.use(pip(options))` between
|
|
30
|
+
`defineApp('{{name}}')` and `.boot()` in `src/app.ts`.
|
|
31
|
+
|
|
32
|
+
## Public / private boundaries
|
|
33
|
+
|
|
34
|
+
- `src/app.ts` exports the booted `app` — consumers call `app.services.X`.
|
|
35
|
+
- `src/env.ts` exports the env schema — keep narrow; only env keys this
|
|
36
|
+
app reads belong here.
|
|
37
|
+
- Don't reach into `@arki/dot` internals (anything under
|
|
38
|
+
`@arki/dot/kernel`, `@arki/dot/legacy`, or `dist/` subpaths). Use the
|
|
39
|
+
public `defineApp` / `defineDotPip` API from `@arki/dot` and the
|
|
40
|
+
`defineDotPip` symbol from `@arki/dot/pip`.
|
|
41
|
+
|
|
42
|
+
## DOT artifact locations
|
|
43
|
+
|
|
44
|
+
- Static graph: `app.manifest` (or `bunx dot explain --json`).
|
|
45
|
+
- Runtime health: `app.diagnostics` (or `bunx dot doctor --json`).
|
|
46
|
+
- Lifecycle state: `app.state` (`defined` -> `configured` -> `booted` ->
|
|
47
|
+
`started` -> `stopped` -> `disposed`).
|
|
48
|
+
- Errors carry stable `code`, `severity`, `remediation`, `docsUrl`.
|
|
49
|
+
|
|
50
|
+
## Adding a pip
|
|
51
|
+
|
|
52
|
+
1. Install the adapter package: `{{pkgManager}} add @arki/<pkg>`.
|
|
53
|
+
2. Import its DOT adapter: `import { <pip> } from '@arki/<pkg>/dot';`.
|
|
54
|
+
3. Chain it into the builder before `.boot()`:
|
|
55
|
+
`.use(<pip>(options))`.
|
|
56
|
+
4. Verify with `bunx dot explain --json` — the new pip should appear
|
|
57
|
+
under `.data.pips`.
|
|
58
|
+
|
|
59
|
+
## Diagnostics triage
|
|
60
|
+
|
|
61
|
+
When `dot doctor` reports issues:
|
|
62
|
+
|
|
63
|
+
- Each `DiagnosticIssue` has a stable `code`, `severity`, `remediation`,
|
|
64
|
+
and `docsUrl`. Follow the `docsUrl`, then apply the `remediation`.
|
|
65
|
+
- Re-run `bunx dot doctor --json` after each change; status flips to
|
|
66
|
+
`success` once every `error`-severity issue is resolved.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
A DOT-composed application.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
{{pkgManager}} install
|
|
9
|
+
{{pkgManager}} run test
|
|
10
|
+
{{pkgManager}} run boot
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Inspect
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bunx dot explain --json
|
|
17
|
+
bunx dot doctor --json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`dot explain` prints the static graph (pips, services, routes, dependencies,
|
|
21
|
+
lifecycle hooks). `dot doctor` boots the app and prints the runtime
|
|
22
|
+
diagnostics envelope (the same five arrays, plus issues).
|
|
23
|
+
|
|
24
|
+
See [AGENTS.md](./AGENTS.md) for agent-readable conventions.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"test": "vitest run",
|
|
9
|
+
"typecheck": "tsc --noEmit",
|
|
10
|
+
"boot": "node --experimental-strip-types src/app.ts"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@arki/dot": "^{{dotVersion}}",
|
|
14
|
+
"@arki/env": "^{{envVersion}}",
|
|
15
|
+
"zod": "^{{zodVersion}}"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0",
|
|
19
|
+
"vitest": "^2.1.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineApp } from '@arki/dot';
|
|
2
|
+
import { env } from '@arki/env/dot';
|
|
3
|
+
|
|
4
|
+
import { envSchema } from './env.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* App builder. Exported as both `app` (for tests that want to boot
|
|
8
|
+
* synchronously inside a `test(...)` block) and as the module default
|
|
9
|
+
* (so `dot explain` / `dot doctor` can discover it via the CLI).
|
|
10
|
+
*/
|
|
11
|
+
export const app = defineApp('{{name}}').use(env({ schema: envSchema }));
|
|
12
|
+
|
|
13
|
+
export default app;
|
|
14
|
+
|
|
15
|
+
if ((import.meta as { main?: boolean }).main) {
|
|
16
|
+
const booted = await app.boot();
|
|
17
|
+
// Intentional console use — this branch only runs as a script.
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log(JSON.stringify(booted.manifest, null, 2));
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const envSchema = {
|
|
4
|
+
NODE_ENV: z
|
|
5
|
+
.enum(['development', 'test', 'production'])
|
|
6
|
+
.default('development'),
|
|
7
|
+
// Add your env keys here.
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type Env = {
|
|
11
|
+
readonly [K in keyof typeof envSchema]: z.infer<(typeof envSchema)[K]>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { beforeAll, expect, test } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { app as appBuilder } from '../src/app.js';
|
|
4
|
+
|
|
5
|
+
type BootedApp = Awaited<ReturnType<typeof appBuilder.boot>>;
|
|
6
|
+
let booted: BootedApp;
|
|
7
|
+
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
booted = await appBuilder.boot();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('app boots and exposes env service', () => {
|
|
13
|
+
expect(booted.state).toBe('booted');
|
|
14
|
+
expect(booted.services.env).toBeDefined();
|
|
15
|
+
expect(booted.manifest.services.map(s => s.name)).toContain('env');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('diagnostics has all 5 arrays', () => {
|
|
19
|
+
const { diagnostics } = booted;
|
|
20
|
+
expect(diagnostics.pips).toBeDefined();
|
|
21
|
+
expect(diagnostics.routes).toBeDefined();
|
|
22
|
+
expect(diagnostics.services).toBeDefined();
|
|
23
|
+
expect(diagnostics.lifecycle).toBeDefined();
|
|
24
|
+
expect(diagnostics.issues).toBeDefined();
|
|
25
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"noUncheckedIndexedAccess": true,
|
|
12
|
+
"noImplicitOverride": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"verbatimModuleSyntax": true,
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
"declaration": true,
|
|
18
|
+
"sourceMap": true
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*", "tests/**/*"],
|
|
21
|
+
"exclude": ["node_modules", "dist"]
|
|
22
|
+
}
|