@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,456 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `dot` CLI entry point.
4
+ *
5
+ * Two commands are wired today (more land in v1.1):
6
+ * - `dot explain` — print the static app graph (manifest)
7
+ * - `dot doctor` — boot the app and print runtime diagnostics
8
+ *
9
+ * Common options:
10
+ * --json Emit JSON envelope instead of human-readable text
11
+ * --app <p> Path to the app file (overrides auto-discovery)
12
+ * --cwd <p> Working directory (default: process.cwd())
13
+ * --help Show help
14
+ * --version Print version
15
+ *
16
+ * Exit codes: `0` on success/warning envelopes (doctor warnings still mean the
17
+ * app booted), `1` on `failure` envelopes and on every structured CLI error.
18
+ */
19
+ import { parseArgs as nodeParseArgs } from 'node:util';
20
+ import { createDebugLogger } from '@arki/log/debug';
21
+ import { DotLifecycleError } from '../lifecycle.js';
22
+ import { discoverApp, guards } from './discover.js';
23
+ import { DotCliError, DotCliErrorCode, dotCliDocsUrl } from './error-codes.js';
24
+ import { runNew } from './new.js';
25
+ import { probeObservability } from './observability-probe.js';
26
+ import { renderDoctor } from './render-doctor.js';
27
+ import { renderExplain } from './render-explain.js';
28
+ const debugCli = createDebugLogger('arki:dot:cli');
29
+ const VERSION = '0.1.0';
30
+ const HELP_TEXT = `dot — CLI for inspecting and scaffolding DOT apps
31
+
32
+ Usage:
33
+ dot <command> [options]
34
+
35
+ Commands:
36
+ explain Print the static app graph (manifest)
37
+ doctor Boot the app and print runtime diagnostics
38
+ new <app-name> Scaffold a minimal DOT app
39
+
40
+ Common options:
41
+ --json Emit a JSON envelope to stdout (default: text)
42
+ --help Show this help and exit
43
+ --version Print version and exit
44
+
45
+ \`explain\` / \`doctor\` options:
46
+ --app <path> Path to the app entry file (default: discovers
47
+ ./dot.config.ts, ./src/app.ts, or ./app.ts)
48
+ --cwd <dir> Working directory (default: current)
49
+
50
+ \`doctor\` options:
51
+ --observability Also probe whether an OpenTelemetry SDK is
52
+ registered. Surfaces a warning issue when not,
53
+ pointing at the docs to wire one in.
54
+
55
+ \`new\` options:
56
+ --target <dir> Directory to create the app in (default: <app-name>)
57
+ --pm <npm|pnpm|bun> Package manager hint for the README (default: bun)
58
+ --dry-run Print planned file operations without writing
59
+ --force Overwrite existing files in the target directory
60
+ `;
61
+ /**
62
+ * Parse argv into a typed shape. Exported so tests can exercise it without
63
+ * spawning the binary.
64
+ */
65
+ export function parseArgs(argv) {
66
+ // Extract the (optional) leading positional command; node:util parseArgs
67
+ // wants every positional to come *after* flags by default, but we want
68
+ // `dot explain --json` to parse correctly.
69
+ const rest = [...argv];
70
+ let command = null;
71
+ // Pull off the first positional that doesn't look like a flag.
72
+ for (let i = 0; i < rest.length; i++) {
73
+ const tok = rest[i];
74
+ if (!tok.startsWith('-')) {
75
+ const cmd = tok;
76
+ if (cmd === 'explain' || cmd === 'doctor' || cmd === 'new' || cmd === 'help' || cmd === 'version') {
77
+ command = cmd;
78
+ rest.splice(i, 1);
79
+ break;
80
+ }
81
+ throw new DotCliError({
82
+ code: DotCliErrorCode.UnknownCommand,
83
+ message: `Unknown command: ${cmd}`,
84
+ remediation: 'Use one of: explain, doctor, new. Run `dot --help` for usage.',
85
+ metadata: { received: cmd },
86
+ });
87
+ }
88
+ }
89
+ // `new` takes a positional <app-name> after the command. Pull the next
90
+ // non-flag token out so node:util parseArgs doesn't see it.
91
+ let positional;
92
+ if (command === 'new') {
93
+ for (let i = 0; i < rest.length; i++) {
94
+ const tok = rest[i];
95
+ if (!tok.startsWith('-')) {
96
+ positional = tok;
97
+ rest.splice(i, 1);
98
+ break;
99
+ }
100
+ }
101
+ }
102
+ let parsed;
103
+ try {
104
+ parsed = nodeParseArgs({
105
+ args: rest,
106
+ strict: true,
107
+ allowPositionals: false,
108
+ options: {
109
+ json: { type: 'boolean', default: false },
110
+ app: { type: 'string' },
111
+ cwd: { type: 'string' },
112
+ help: { type: 'boolean', default: false },
113
+ version: { type: 'boolean', default: false },
114
+ target: { type: 'string' },
115
+ pm: { type: 'string' },
116
+ 'dry-run': { type: 'boolean', default: false },
117
+ force: { type: 'boolean', default: false },
118
+ observability: { type: 'boolean', default: false },
119
+ },
120
+ });
121
+ }
122
+ catch (err) {
123
+ throw new DotCliError({
124
+ code: DotCliErrorCode.InvalidArgs,
125
+ message: `Invalid CLI arguments: ${err instanceof Error ? err.message : String(err)}`,
126
+ remediation: 'Run `dot --help` to see supported options.',
127
+ cause: err,
128
+ });
129
+ }
130
+ const values = parsed.values;
131
+ if (values.help)
132
+ command = 'help';
133
+ if (values.version)
134
+ command = 'version';
135
+ if (!command)
136
+ command = 'help';
137
+ let pm;
138
+ if (values.pm !== undefined) {
139
+ if (values.pm !== 'npm' && values.pm !== 'pnpm' && values.pm !== 'bun') {
140
+ throw new DotCliError({
141
+ code: DotCliErrorCode.InvalidArgs,
142
+ message: `Invalid --pm value: ${values.pm}`,
143
+ remediation: 'Use one of: npm, pnpm, bun.',
144
+ metadata: { received: values.pm },
145
+ });
146
+ }
147
+ pm = values.pm;
148
+ }
149
+ return {
150
+ command,
151
+ json: values.json ?? false,
152
+ appPath: values.app,
153
+ cwd: values.cwd,
154
+ positional,
155
+ target: values.target,
156
+ pm,
157
+ dryRun: values['dry-run'] ?? false,
158
+ force: values.force ?? false,
159
+ observability: values.observability ?? false,
160
+ };
161
+ }
162
+ /** Discovery wrapper — returns `null` for help/version commands. */
163
+ async function loadApp(args) {
164
+ const { app } = await discoverApp({ appPath: args.appPath, cwd: args.cwd });
165
+ return app;
166
+ }
167
+ /**
168
+ * Run `explain` on a discovered app.
169
+ * Pure dependency on a `DiscoveredApp` so tests can pass synthetic values.
170
+ */
171
+ export async function runExplain(discovered, opts) {
172
+ let configured;
173
+ try {
174
+ if (guards.isDotAppBuilder(discovered)) {
175
+ // explain never boots — just configure.
176
+ configured = discovered.configure();
177
+ }
178
+ else {
179
+ configured = discovered;
180
+ }
181
+ }
182
+ catch (err) {
183
+ throw wrapLifecycleError(err, 'configure');
184
+ }
185
+ return renderExplain({ manifest: configured.manifest }, { json: opts.json, out: opts.out, now: opts.now });
186
+ }
187
+ /**
188
+ * Run `doctor` on a discovered app. The CLI owns boot+dispose only when it
189
+ * receives a builder. If the caller passed an already-booted app, we leave
190
+ * lifecycle to them.
191
+ *
192
+ * If `boot()` throws, doctor's job is still to surface diagnostics — so we
193
+ * pre-configure the builder, then re-read the configured seam's diagnostics
194
+ * even after a boot throw. This is the whole point of `doctor`: failure
195
+ * should be observable, not opaque.
196
+ */
197
+ export async function runDoctor(discovered, opts) {
198
+ // Already-booted app: just read diagnostics, don't touch lifecycle.
199
+ if (!guards.isDotAppBuilder(discovered) && !guards.isDotAppConfigured(discovered)) {
200
+ const app = discovered;
201
+ const diagnostics = applyObservabilityProbe(app.diagnostics, opts.observability ?? false);
202
+ return renderDoctor({ diagnostics }, { json: opts.json, out: opts.out, now: opts.now });
203
+ }
204
+ // Builder or configured seam: drive lifecycle ourselves. Boot failures fall
205
+ // back to the configured seam's diagnostics so per-pip issues stay
206
+ // visible.
207
+ let configured;
208
+ try {
209
+ configured = guards.isDotAppBuilder(discovered)
210
+ ? discovered.configure()
211
+ : discovered;
212
+ }
213
+ catch (err) {
214
+ throw wrapLifecycleError(err, 'configure');
215
+ }
216
+ let bootedApp = null;
217
+ let bootThrew = false;
218
+ try {
219
+ bootedApp = await configured.boot();
220
+ }
221
+ catch (err) {
222
+ // Boot failed — surface diagnostics from the configured seam below.
223
+ // We deliberately swallow the throw so the user sees the per-pip
224
+ // issues instead of an opaque wrapper error.
225
+ bootThrew = true;
226
+ debugCli('boot threw, falling back to configured diagnostics: %O', err);
227
+ }
228
+ try {
229
+ const rawDiagnostics = bootedApp ? bootedApp.diagnostics : configured.diagnostics;
230
+ const diagnostics = applyObservabilityProbe(rawDiagnostics, opts.observability ?? false);
231
+ const envelope = renderDoctor({ diagnostics }, { json: opts.json, out: opts.out, now: opts.now });
232
+ // Sanity: if boot threw, the envelope SHOULD be failure already (kernel
233
+ // populates issues on boot failure). If somehow it isn't, downgrade
234
+ // status to surface the failure.
235
+ if (bootThrew && envelope.status === 'success') {
236
+ return { ...envelope, status: 'failure' };
237
+ }
238
+ return envelope;
239
+ }
240
+ finally {
241
+ if (bootedApp) {
242
+ try {
243
+ await bootedApp.dispose();
244
+ }
245
+ catch (err) {
246
+ debugCli('dispose threw: %O', err);
247
+ }
248
+ }
249
+ }
250
+ }
251
+ /**
252
+ * Run the observability probe and fold its issue (if any) into the
253
+ * top-level `issues` array. Returns a new snapshot — never mutates the
254
+ * input.
255
+ */
256
+ function applyObservabilityProbe(diagnostics, enabled) {
257
+ if (!enabled)
258
+ return diagnostics;
259
+ const probeIssue = probeObservability();
260
+ if (!probeIssue)
261
+ return diagnostics;
262
+ return { ...diagnostics, issues: [...diagnostics.issues, probeIssue] };
263
+ }
264
+ function wrapLifecycleError(err, phase) {
265
+ if (err instanceof DotCliError)
266
+ return err;
267
+ const isLifecycleError = err instanceof DotLifecycleError;
268
+ const message = err instanceof Error ? err.message : String(err);
269
+ const code = isLifecycleError ? err.code : 'UNKNOWN';
270
+ return new DotCliError({
271
+ code: DotCliErrorCode.AppLifecycleFailed,
272
+ message: `App ${phase} failed: ${message}`,
273
+ remediation: phase === 'configure'
274
+ ? 'Check the pips registered in your app for a synchronous `configure` hook that throws or returns a Promise. Run `dot doctor` for per-pip diagnostics.'
275
+ : 'Run `dot doctor` to see per-pip diagnostics. The boot hook for one of your pips failed.',
276
+ metadata: { phase, underlyingCode: code },
277
+ cause: err,
278
+ });
279
+ }
280
+ /**
281
+ * Convert a `DotCliError` into a synthetic envelope so JSON consumers see a
282
+ * uniform shape regardless of failure mode.
283
+ */
284
+ function errorEnvelope(err, command, now) {
285
+ const issue = {
286
+ code: err.code,
287
+ severity: 'error',
288
+ message: err.message,
289
+ remediation: err.remediation,
290
+ docsUrl: err.docsUrl,
291
+ metadata: err.metadata,
292
+ };
293
+ return {
294
+ status: 'failure',
295
+ command,
296
+ generatedAt: now().toISOString(),
297
+ data: null,
298
+ errors: [issue],
299
+ };
300
+ }
301
+ /**
302
+ * Run the CLI. Returns the exit code so tests can assert without calling
303
+ * `process.exit`. Real entry point at the bottom of the file calls `exit()`.
304
+ */
305
+ export async function main(options) {
306
+ const stdout = options.stdout ?? ((line) => process.stdout.write(line));
307
+ const stderr = options.stderr ?? ((line) => process.stderr.write(line));
308
+ const nowFactory = options.now ?? (() => new Date());
309
+ let args;
310
+ try {
311
+ args = parseArgs(options.argv);
312
+ }
313
+ catch (err) {
314
+ if (err instanceof DotCliError) {
315
+ const envelope = errorEnvelope(err, 'unknown', nowFactory);
316
+ stderr(`${JSON.stringify(envelope, null, 2)}\n`);
317
+ return 1;
318
+ }
319
+ throw err;
320
+ }
321
+ if (args.command === 'help') {
322
+ stdout(HELP_TEXT);
323
+ return 0;
324
+ }
325
+ if (args.command === 'version') {
326
+ stdout(`${VERSION}\n`);
327
+ return 0;
328
+ }
329
+ if (args.command === 'new') {
330
+ if (!args.positional) {
331
+ const err = new DotCliError({
332
+ code: DotCliErrorCode.InvalidArgs,
333
+ message: 'Missing required <app-name> positional for `dot new`.',
334
+ remediation: 'Run `dot new <app-name>`. Example: `dot new my-app`.',
335
+ });
336
+ const envelope = errorEnvelope(err, 'new', nowFactory);
337
+ if (args.json)
338
+ stdout(`${JSON.stringify(envelope, null, 2)}\n`);
339
+ else
340
+ stderr(formatErrorText(err));
341
+ return 1;
342
+ }
343
+ try {
344
+ const envelope = await runNew({
345
+ name: args.positional,
346
+ cwd: args.cwd,
347
+ target: args.target,
348
+ pm: args.pm,
349
+ dryRun: args.dryRun,
350
+ json: args.json,
351
+ force: args.force,
352
+ out: stdout,
353
+ err: stderr,
354
+ now: nowFactory,
355
+ });
356
+ return envelope.status === 'failure' ? 1 : 0;
357
+ }
358
+ catch (err) {
359
+ if (err instanceof DotCliError) {
360
+ const envelope = errorEnvelope(err, 'new', nowFactory);
361
+ if (args.json)
362
+ stdout(`${JSON.stringify(envelope, null, 2)}\n`);
363
+ else
364
+ stderr(formatErrorText(err));
365
+ return 1;
366
+ }
367
+ throw err;
368
+ }
369
+ }
370
+ try {
371
+ const discovered = await loadApp(args);
372
+ const opts = { json: args.json, out: stdout, now: nowFactory };
373
+ let envelope;
374
+ if (args.command === 'explain') {
375
+ envelope = await runExplain(discovered, opts);
376
+ }
377
+ else {
378
+ envelope = await runDoctor(discovered, { ...opts, observability: args.observability });
379
+ }
380
+ return envelopeExitCode(envelope.status);
381
+ }
382
+ catch (err) {
383
+ if (err instanceof DotCliError) {
384
+ const envelope = errorEnvelope(err, args.command, nowFactory);
385
+ if (args.json) {
386
+ stdout(`${JSON.stringify(envelope, null, 2)}\n`);
387
+ }
388
+ else {
389
+ stderr(formatErrorText(err));
390
+ }
391
+ return 1;
392
+ }
393
+ // Last-resort path: an exception escaped without being wrapped. Surface
394
+ // it as a structured envelope rather than dumping a stack trace.
395
+ const fallback = new DotCliError({
396
+ code: DotCliErrorCode.AppLifecycleFailed,
397
+ message: err instanceof Error ? err.message : String(err),
398
+ remediation: 'See debug logs (DEBUG=arki:dot:cli) for context. Re-run with --json for machine-readable output.',
399
+ cause: err,
400
+ });
401
+ const envelope = errorEnvelope(fallback, args.command, nowFactory);
402
+ if (args.json) {
403
+ stdout(`${JSON.stringify(envelope, null, 2)}\n`);
404
+ }
405
+ else {
406
+ stderr(formatErrorText(fallback));
407
+ }
408
+ return 1;
409
+ }
410
+ }
411
+ function envelopeExitCode(status) {
412
+ return status === 'failure' ? 1 : 0;
413
+ }
414
+ function formatErrorText(err) {
415
+ return [
416
+ `dot: ${err.code} ${err.message}`,
417
+ ` remediation: ${err.remediation}`,
418
+ ` docs: ${err.docsUrl}`,
419
+ '',
420
+ ].join('\n');
421
+ }
422
+ /**
423
+ * Re-exports for test consumers and adapter packages.
424
+ */
425
+ export { DotCliError, DotCliErrorCode, dotCliDocsUrl };
426
+ export { runNew } from './new.js';
427
+ // Direct-execution guard: only spin up the CLI when this module is the entry
428
+ // point, not when it's imported (e.g. by tests).
429
+ const isMainModule = await (async () => {
430
+ try {
431
+ // Bun sets `import.meta.main` when running as the entry script.
432
+ if (typeof import.meta.main === 'boolean') {
433
+ return import.meta.main;
434
+ }
435
+ }
436
+ catch {
437
+ /* ignore */
438
+ }
439
+ // Node fallback: compare argv[1]'s resolved file URL with import.meta.url.
440
+ try {
441
+ const entry = process.argv[1];
442
+ if (typeof entry !== 'string')
443
+ return false;
444
+ const { pathToFileURL } = await import('node:url');
445
+ return pathToFileURL(entry).href === import.meta.url;
446
+ }
447
+ catch {
448
+ return false;
449
+ }
450
+ })();
451
+ if (isMainModule) {
452
+ void main({ argv: process.argv.slice(2) }).then(code => {
453
+ process.exit(code);
454
+ });
455
+ }
456
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SA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,EAAE,MAAM,UAAU,CAAC;AAGlC,6EAA6E;AAC7E,iDAAiD;AACjD,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE;IACrC,IAAI,CAAC;QACH,gEAAgE;QAChE,IAAI,OAAQ,MAAM,CAAC,IAA2B,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAClE,OAAQ,MAAM,CAAC,IAA0B,CAAC,IAAI,CAAC;QACjD,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,YAAY;IACd,CAAC;IACD,2EAA2E;IAC3E,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QACnD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAEL,IAAI,YAAY,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACrD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * JSON envelope shapes for the `dot new` command.
3
+ *
4
+ * The envelope mirrors `DotCliEnvelope` in spirit but exposes the
5
+ * scaffold-specific `app` + `operations` payload directly at the top level
6
+ * so consumers don't have to dig under a generic `data` field.
7
+ */
8
+ import type { DiagnosticIssue } from '../diagnostics.js';
9
+ import type { FileOperation } from './files.js';
10
+ /** Subset of {@link FileOperation} emitted in the JSON envelope. */
11
+ export type DotNewOperation = {
12
+ readonly path: string;
13
+ readonly action: FileOperation['action'];
14
+ readonly contentHash: string;
15
+ readonly contentBytes: number;
16
+ readonly reason: string;
17
+ };
18
+ /**
19
+ * Envelope returned by `dot new`. Both dry-run and real runs share the
20
+ * same shape, distinguished only by `errors` and per-operation `action`.
21
+ *
22
+ * `errors` carries the same {@link DiagnosticIssue} shape used everywhere
23
+ * else in the CLI — agents already parse it.
24
+ */
25
+ export type DotNewEnvelope = {
26
+ readonly status: 'success' | 'failure';
27
+ readonly command: 'new';
28
+ readonly generatedAt: string;
29
+ readonly app: {
30
+ readonly name: string;
31
+ readonly target: string;
32
+ };
33
+ readonly operations: readonly DotNewOperation[];
34
+ readonly errors: readonly DiagnosticIssue[];
35
+ };
36
+ /** Strip the in-memory `content` field before serialising. */
37
+ export declare function toPublicOperation(op: FileOperation): DotNewOperation;
38
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/cli/json.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE;QACZ,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C,CAAC;AAEF,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,aAAa,GAAG,eAAe,CAQpE"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * JSON envelope shapes for the `dot new` command.
3
+ *
4
+ * The envelope mirrors `DotCliEnvelope` in spirit but exposes the
5
+ * scaffold-specific `app` + `operations` payload directly at the top level
6
+ * so consumers don't have to dig under a generic `data` field.
7
+ */
8
+ /** Strip the in-memory `content` field before serialising. */
9
+ export function toPublicOperation(op) {
10
+ return {
11
+ path: op.path,
12
+ action: op.action,
13
+ contentHash: op.contentHash,
14
+ contentBytes: op.contentBytes,
15
+ reason: op.reason,
16
+ };
17
+ }
18
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/cli/json.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiCH,8DAA8D;AAC9D,MAAM,UAAU,iBAAiB,CAAC,EAAiB;IACjD,OAAO;QACL,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,MAAM,EAAE,EAAE,CAAC,MAAM;QACjB,WAAW,EAAE,EAAE,CAAC,WAAW;QAC3B,YAAY,EAAE,EAAE,CAAC,YAAY;QAC7B,MAAM,EAAE,EAAE,CAAC,MAAM;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * `dot new <app>` — scaffold a minimal DOT app.
3
+ *
4
+ * Two-phase: we first build an in-memory list of {@link FileOperation}
5
+ * entries describing every file the scaffold WOULD write (template
6
+ * substitution included), then either:
7
+ *
8
+ * - `--dry-run` -> print the JSON envelope, write nothing.
9
+ * - real run -> commit the planned operations to disk.
10
+ *
11
+ * The dry-run envelope is the contract: agents read it to know exactly
12
+ * which files will land, with sha256 hashes so they can verify the
13
+ * post-run filesystem matches the plan.
14
+ *
15
+ * Templates live at `packages/dot/templates/app-minimal/` and use
16
+ * `.tmpl` suffixes + `{{name}}`-style placeholders. The suffix is
17
+ * stripped during scaffolding so `package.json.tmpl` becomes
18
+ * `package.json` on disk.
19
+ *
20
+ * Commands deferred to v1.1 (`dot add <pip>`, `dot dev`,
21
+ * `dot migrate`) are deliberately NOT surfaced here.
22
+ */
23
+ import type { FileOperation } from './files.js';
24
+ import type { DotNewEnvelope } from './json.js';
25
+ /**
26
+ * Package manager the generated README + AGENTS.md will reference.
27
+ * `bun` is the default because the kernel + adapter packages are tested
28
+ * with Bun first.
29
+ */
30
+ export type PackageManager = 'npm' | 'pnpm' | 'bun';
31
+ /** Options accepted by {@link runNew}. */
32
+ export type RunNewOptions = {
33
+ /** Application name (becomes `package.json#name`). */
34
+ readonly name: string;
35
+ /**
36
+ * Working directory for resolving `--target`. Defaults to
37
+ * `process.cwd()` when omitted.
38
+ */
39
+ readonly cwd?: string;
40
+ /**
41
+ * Target directory; resolved against `cwd`. Defaults to `<name>`
42
+ * under `cwd`. The directory is created if missing.
43
+ */
44
+ readonly target?: string;
45
+ /** Package manager hint surfaced in README/AGENTS.md. Defaults to `bun`. */
46
+ readonly pm?: PackageManager;
47
+ /** When true, only plan operations — write nothing. */
48
+ readonly dryRun?: boolean;
49
+ /** When true, emit JSON to `out`. Otherwise emit progress lines. */
50
+ readonly json?: boolean;
51
+ /** When true, overwrite existing files in the target dir. */
52
+ readonly force?: boolean;
53
+ /** Stdout sink. Defaults to `process.stdout.write`. */
54
+ readonly out?: (line: string) => void;
55
+ /** Stderr sink. Defaults to `process.stderr.write`. */
56
+ readonly err?: (line: string) => void;
57
+ /** Override clock for deterministic envelopes. */
58
+ readonly now?: () => Date;
59
+ /**
60
+ * Override template root. Used by tests; production callers should
61
+ * leave this undefined so the bundled `templates/app-minimal/`
62
+ * directory is used.
63
+ */
64
+ readonly templateRoot?: string;
65
+ /**
66
+ * Version values inlined into the generated `package.json`. The
67
+ * defaults track the current `@arki/dot` + `@arki/env` releases.
68
+ */
69
+ readonly versions?: {
70
+ readonly dot?: string;
71
+ readonly env?: string;
72
+ readonly zod?: string;
73
+ };
74
+ };
75
+ /**
76
+ * Resolve the absolute target path for a given app + options bundle.
77
+ * Exported so tests can assert resolution behaviour without running the
78
+ * full scaffold.
79
+ */
80
+ export declare function resolveTargetDir(opts: {
81
+ name: string;
82
+ cwd?: string;
83
+ target?: string;
84
+ }): string;
85
+ /**
86
+ * Validate an app name. Rules match `package.json#name` constraints
87
+ * (lower-case, leading alphanumeric, no spaces) with one extra: we
88
+ * disallow scoped names so the scaffold produces a single-segment dir.
89
+ */
90
+ export declare function validateAppName(name: string): void;
91
+ /**
92
+ * Plan the file operations for a scaffold run. Pure — does not touch
93
+ * disk other than reading templates and `stat`-ing target paths.
94
+ */
95
+ export declare function planOperations(opts: RunNewOptions): Promise<{
96
+ operations: FileOperation[];
97
+ target: string;
98
+ }>;
99
+ /**
100
+ * Run the `new` command. Returns the envelope so callers (CLI + tests)
101
+ * can act on it. Side effects: writes files when not in dry-run mode,
102
+ * emits progress to `out`/`err`.
103
+ */
104
+ export declare function runNew(opts: RunNewOptions): Promise<DotNewEnvelope>;
105
+ //# sourceMappingURL=new.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../src/cli/new.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WA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