@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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +201 -0
  3. package/dist/cli/discover.d.ts +65 -0
  4. package/dist/cli/discover.d.ts.map +1 -0
  5. package/dist/cli/discover.js +184 -0
  6. package/dist/cli/discover.js.map +1 -0
  7. package/dist/cli/error-codes.d.ts +49 -0
  8. package/dist/cli/error-codes.d.ts.map +1 -0
  9. package/dist/cli/error-codes.js +61 -0
  10. package/dist/cli/error-codes.js.map +1 -0
  11. package/dist/cli/files.d.ts +67 -0
  12. package/dist/cli/files.d.ts.map +1 -0
  13. package/dist/cli/files.js +80 -0
  14. package/dist/cli/files.js.map +1 -0
  15. package/dist/cli/index.d.ts +95 -0
  16. package/dist/cli/index.d.ts.map +1 -0
  17. package/dist/cli/index.js +456 -0
  18. package/dist/cli/index.js.map +1 -0
  19. package/dist/cli/json.d.ts +38 -0
  20. package/dist/cli/json.d.ts.map +1 -0
  21. package/dist/cli/json.js +18 -0
  22. package/dist/cli/json.js.map +1 -0
  23. package/dist/cli/new.d.ts +105 -0
  24. package/dist/cli/new.d.ts.map +1 -0
  25. package/dist/cli/new.js +322 -0
  26. package/dist/cli/new.js.map +1 -0
  27. package/dist/cli/observability-probe.d.ts +28 -0
  28. package/dist/cli/observability-probe.d.ts.map +1 -0
  29. package/dist/cli/observability-probe.js +44 -0
  30. package/dist/cli/observability-probe.js.map +1 -0
  31. package/dist/cli/render-doctor.d.ts +26 -0
  32. package/dist/cli/render-doctor.d.ts.map +1 -0
  33. package/dist/cli/render-doctor.js +183 -0
  34. package/dist/cli/render-doctor.js.map +1 -0
  35. package/dist/cli/render-explain.d.ts +43 -0
  36. package/dist/cli/render-explain.d.ts.map +1 -0
  37. package/dist/cli/render-explain.js +127 -0
  38. package/dist/cli/render-explain.js.map +1 -0
  39. package/dist/define-app.d.ts +125 -0
  40. package/dist/define-app.d.ts.map +1 -0
  41. package/dist/define-app.js +126 -0
  42. package/dist/define-app.js.map +1 -0
  43. package/dist/dependency-graph.d.ts +25 -0
  44. package/dist/dependency-graph.d.ts.map +1 -0
  45. package/dist/dependency-graph.js +86 -0
  46. package/dist/dependency-graph.js.map +1 -0
  47. package/dist/diagnostics.d.ts +83 -0
  48. package/dist/diagnostics.d.ts.map +1 -0
  49. package/dist/diagnostics.js +14 -0
  50. package/dist/diagnostics.js.map +1 -0
  51. package/dist/index.d.ts +24 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +17 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/kernel/app-instance.d.ts +62 -0
  56. package/dist/kernel/app-instance.d.ts.map +1 -0
  57. package/dist/kernel/app-instance.js +1040 -0
  58. package/dist/kernel/app-instance.js.map +1 -0
  59. package/dist/kernel/otel.d.ts +105 -0
  60. package/dist/kernel/otel.d.ts.map +1 -0
  61. package/dist/kernel/otel.js +218 -0
  62. package/dist/kernel/otel.js.map +1 -0
  63. package/dist/lifecycle-observer.d.ts +95 -0
  64. package/dist/lifecycle-observer.d.ts.map +1 -0
  65. package/dist/lifecycle-observer.js +19 -0
  66. package/dist/lifecycle-observer.js.map +1 -0
  67. package/dist/lifecycle.d.ts +94 -0
  68. package/dist/lifecycle.d.ts.map +1 -0
  69. package/dist/lifecycle.js +78 -0
  70. package/dist/lifecycle.js.map +1 -0
  71. package/dist/manifest.d.ts +75 -0
  72. package/dist/manifest.d.ts.map +1 -0
  73. package/dist/manifest.js +14 -0
  74. package/dist/manifest.js.map +1 -0
  75. package/dist/pip-contract.d.ts +219 -0
  76. package/dist/pip-contract.d.ts.map +1 -0
  77. package/dist/pip-contract.js +90 -0
  78. package/dist/pip-contract.js.map +1 -0
  79. package/dist/pip.d.ts +33 -0
  80. package/dist/pip.d.ts.map +1 -0
  81. package/dist/pip.js +25 -0
  82. package/dist/pip.js.map +1 -0
  83. package/dist/plugin-contract.d.ts +175 -0
  84. package/dist/plugin-contract.d.ts.map +1 -0
  85. package/dist/plugin-contract.js +45 -0
  86. package/dist/plugin-contract.js.map +1 -0
  87. package/dist/plugin.d.ts +30 -0
  88. package/dist/plugin.d.ts.map +1 -0
  89. package/dist/plugin.js +24 -0
  90. package/dist/plugin.js.map +1 -0
  91. package/dist/test-harness.d.ts +42 -0
  92. package/dist/test-harness.d.ts.map +1 -0
  93. package/dist/test-harness.js +46 -0
  94. package/dist/test-harness.js.map +1 -0
  95. package/dist/timeline.d.ts +43 -0
  96. package/dist/timeline.d.ts.map +1 -0
  97. package/dist/timeline.js +121 -0
  98. package/dist/timeline.js.map +1 -0
  99. package/package.json +68 -0
  100. package/templates/app-minimal/.gitignore.tmpl +6 -0
  101. package/templates/app-minimal/AGENTS.md.tmpl +66 -0
  102. package/templates/app-minimal/README.md.tmpl +24 -0
  103. package/templates/app-minimal/package.json.tmpl +21 -0
  104. package/templates/app-minimal/src/app.ts.tmpl +20 -0
  105. package/templates/app-minimal/src/env.ts.tmpl +12 -0
  106. package/templates/app-minimal/tests/boot.test.ts.tmpl +25 -0
  107. 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
+ }