@orbitpanel/cli 1.2.0 → 1.3.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 (46) hide show
  1. package/dist/commands/init.d.ts +13 -0
  2. package/dist/commands/init.js +65 -0
  3. package/dist/commands/init.js.map +1 -0
  4. package/dist/components/ShellApp.js +40 -5
  5. package/dist/components/ShellApp.js.map +1 -1
  6. package/dist/components/StatusBar.d.ts +3 -0
  7. package/dist/components/StatusBar.js +15 -2
  8. package/dist/components/StatusBar.js.map +1 -1
  9. package/dist/lib/command-router.js +61 -0
  10. package/dist/lib/command-router.js.map +1 -1
  11. package/dist/lib/context-health.d.ts +37 -0
  12. package/dist/lib/context-health.js +162 -0
  13. package/dist/lib/context-health.js.map +1 -0
  14. package/dist/lib/environment.d.ts +19 -0
  15. package/dist/lib/environment.js +75 -0
  16. package/dist/lib/environment.js.map +1 -0
  17. package/dist/lib/init-logic.d.ts +27 -0
  18. package/dist/lib/init-logic.js +34 -0
  19. package/dist/lib/init-logic.js.map +1 -0
  20. package/dist/lib/instructions.d.ts +18 -0
  21. package/dist/lib/instructions.js +37 -0
  22. package/dist/lib/instructions.js.map +1 -0
  23. package/dist/lib/manifest.d.ts +38 -0
  24. package/dist/lib/manifest.js +237 -0
  25. package/dist/lib/manifest.js.map +1 -0
  26. package/dist/lib/prompt-history.d.ts +30 -0
  27. package/dist/lib/prompt-history.js +75 -0
  28. package/dist/lib/prompt-history.js.map +1 -0
  29. package/dist/lib/shell-hints.d.ts +16 -0
  30. package/dist/lib/shell-hints.js +61 -3
  31. package/dist/lib/shell-hints.js.map +1 -1
  32. package/dist/lib/shell-ink.js +2 -1
  33. package/dist/lib/shell-ink.js.map +1 -1
  34. package/dist/lib/shell-render.js +1 -0
  35. package/dist/lib/shell-render.js.map +1 -1
  36. package/dist/lib/shell.js +6 -3
  37. package/dist/lib/shell.js.map +1 -1
  38. package/dist/lib/status-bar.d.ts +5 -0
  39. package/dist/lib/status-bar.js +24 -7
  40. package/dist/lib/status-bar.js.map +1 -1
  41. package/dist/state/store.js +46 -3
  42. package/dist/state/store.js.map +1 -1
  43. package/dist/state/types.d.ts +16 -2
  44. package/dist/types.d.ts +76 -0
  45. package/oclif.manifest.json +71 -1
  46. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-health.js","sourceRoot":"","sources":["../../src/lib/context-health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,qEAAqE;AAErE,MAAM,WAAW,GAAuC;IACtD,EAAE,EAAE,CAAC;IACL,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,mDAAmD;AACnD,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAUrC;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAwB;IAC7D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAErC,eAAe;IACf,IAAI,WAAW,GAA8B,IAAI,CAAC;IAClD,IAAI,QAAQ,EAAE,IAAI,EAAE,CAAC;QACnB,WAAW,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC7D,CAAC;SAAM,IAAI,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC1B,WAAW,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC3D,CAAC;IAED,cAAc;IACd,IAAI,WAAW,GAAgD,IAAI,CAAC;IACpE,IAAI,QAAQ,EAAE,WAAW,EAAE,CAAC;QAC1B,WAAW,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IACpE,CAAC;SAAM,IAAI,QAAQ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AAC;QAC3B,IAAI,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Environment detection and mismatch checking for @orbitpanel/cli.
3
+ *
4
+ * Detects environment from URLs using conservative heuristics.
5
+ * Reports mismatches between manifest-declared and detected environments.
6
+ *
7
+ * PRINCIPLE: Never assume production. If detection is ambiguous, return null.
8
+ */
9
+ import type { ProjectManifest, EnvironmentType, EnvironmentCheck } from '../types.js';
10
+ /**
11
+ * Detect environment from a URL using conservative heuristics.
12
+ * Returns null if detection is ambiguous (no false positives).
13
+ */
14
+ export declare function detectEnvironmentFromUrl(url: string | undefined | null): EnvironmentType | null;
15
+ /**
16
+ * Check for environment mismatch between manifest and detected environment.
17
+ * Only reports mismatch when detection is confident (non-null).
18
+ */
19
+ export declare function checkEnvironmentMismatch(manifest: ProjectManifest, url?: string): EnvironmentCheck;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Environment detection and mismatch checking for @orbitpanel/cli.
3
+ *
4
+ * Detects environment from URLs using conservative heuristics.
5
+ * Reports mismatches between manifest-declared and detected environments.
6
+ *
7
+ * PRINCIPLE: Never assume production. If detection is ambiguous, return null.
8
+ */
9
+ /**
10
+ * Detect environment from a URL using conservative heuristics.
11
+ * Returns null if detection is ambiguous (no false positives).
12
+ */
13
+ export function detectEnvironmentFromUrl(url) {
14
+ if (!url || url.trim() === '')
15
+ return null;
16
+ let hostname;
17
+ try {
18
+ // Handle URLs without protocol
19
+ const normalized = url.includes('://') ? url : `http://${url}`;
20
+ hostname = new URL(normalized).hostname.toLowerCase();
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ // Local indicators
26
+ if (hostname === 'localhost' ||
27
+ hostname === '127.0.0.1' ||
28
+ hostname === '0.0.0.0' ||
29
+ hostname === '::1' ||
30
+ hostname.endsWith('.local') ||
31
+ hostname.endsWith('.test') ||
32
+ hostname.endsWith('.localhost')) {
33
+ return 'local';
34
+ }
35
+ // Staging indicators
36
+ if (hostname.startsWith('staging.') ||
37
+ hostname.startsWith('staging-') ||
38
+ hostname.includes('.staging.')) {
39
+ return 'staging';
40
+ }
41
+ // Dev indicators
42
+ if (hostname.startsWith('dev.') ||
43
+ hostname.startsWith('dev-') ||
44
+ hostname.includes('.dev.')) {
45
+ return 'dev';
46
+ }
47
+ // Ambiguous — do NOT assume production
48
+ return null;
49
+ }
50
+ /**
51
+ * Check for environment mismatch between manifest and detected environment.
52
+ * Only reports mismatch when detection is confident (non-null).
53
+ */
54
+ export function checkEnvironmentMismatch(manifest, url) {
55
+ const detectedEnv = detectEnvironmentFromUrl(url);
56
+ // No detection → no mismatch (we can't be sure)
57
+ if (detectedEnv === null) {
58
+ return {
59
+ manifestEnv: manifest.environment,
60
+ detectedEnv: null,
61
+ mismatch: false,
62
+ warning: null,
63
+ };
64
+ }
65
+ const mismatch = detectedEnv !== manifest.environment;
66
+ return {
67
+ manifestEnv: manifest.environment,
68
+ detectedEnv,
69
+ mismatch,
70
+ warning: mismatch
71
+ ? `Ambiente incoerente: manifest=${manifest.environment}, rilevato=${detectedEnv}`
72
+ : null,
73
+ };
74
+ }
75
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/lib/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAA8B;IACrE,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAE3C,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,+BAA+B;QAC/B,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,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EAAE,KAAK;YACf,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,KAAK,QAAQ,CAAC,WAAW,CAAC;IAEtD,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,WAAW;QACX,QAAQ;QACR,OAAO,EAAE,QAAQ;YACf,CAAC,CAAC,iCAAiC,QAAQ,CAAC,WAAW,cAAc,WAAW,EAAE;YAClF,CAAC,CAAC,IAAI;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Init command logic for @orbitpanel/cli.
3
+ *
4
+ * Separated from the oclif command class for testability.
5
+ * The oclif command handles CLI parsing, this handles the logic.
6
+ */
7
+ import type { ProjectManifest, PlatformType, EnvironmentType } from '../types.js';
8
+ import { type ManifestIO } from './manifest.js';
9
+ export interface InitOptions {
10
+ cwd: string;
11
+ name: string;
12
+ platform: PlatformType;
13
+ environment: EnvironmentType;
14
+ force?: boolean;
15
+ io?: ManifestIO;
16
+ log: (message: string) => void;
17
+ }
18
+ export interface InitResult {
19
+ created: boolean;
20
+ alreadyExists: boolean;
21
+ manifest: ProjectManifest | null;
22
+ }
23
+ /**
24
+ * Core init logic — creates .orbit/project.json.
25
+ * Does NOT auto-link to backend. That's `orbit link`.
26
+ */
27
+ export declare function runInit(opts: InitOptions): Promise<InitResult>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Init command logic for @orbitpanel/cli.
3
+ *
4
+ * Separated from the oclif command class for testability.
5
+ * The oclif command handles CLI parsing, this handles the logic.
6
+ */
7
+ import { join } from 'node:path';
8
+ import { MANIFEST_DIR, MANIFEST_FILENAME, saveManifest } from './manifest.js';
9
+ /**
10
+ * Core init logic — creates .orbit/project.json.
11
+ * Does NOT auto-link to backend. That's `orbit link`.
12
+ */
13
+ export async function runInit(opts) {
14
+ const { cwd, name, platform, environment, force, log } = opts;
15
+ // Use provided IO or import default
16
+ const io = opts.io ?? (await import('./manifest.js')).defaultManifestIO;
17
+ // Check if already exists
18
+ const manifestPath = join(cwd, MANIFEST_DIR, MANIFEST_FILENAME);
19
+ if (!force && await io.exists(manifestPath)) {
20
+ log(`Progetto gia inizializzato: ${manifestPath}`);
21
+ log('Usa --force per sovrascrivere.');
22
+ return { created: false, alreadyExists: true, manifest: null };
23
+ }
24
+ const manifest = {
25
+ version: 1,
26
+ name,
27
+ platform,
28
+ environment,
29
+ };
30
+ await saveManifest(cwd, manifest, io);
31
+ log(`Progetto inizializzato: ${cwd}/.orbit/project.json`);
32
+ return { created: true, alreadyExists: false, manifest };
33
+ }
34
+ //# sourceMappingURL=init-logic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-logic.js","sourceRoot":"","sources":["../../src/lib/init-logic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAmB,MAAM,eAAe,CAAC;AAkB/F;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAiB;IAC7C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE9D,oCAAoC;IACpC,MAAM,EAAE,GAAe,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEpF,0BAA0B;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK,IAAI,MAAM,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC5C,GAAG,CAAC,+BAA+B,YAAY,EAAE,CAAC,CAAC;QACnD,GAAG,CAAC,gCAAgC,CAAC,CAAC;QACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjE,CAAC;IAED,MAAM,QAAQ,GAAoB;QAChC,OAAO,EAAE,CAAC;QACV,IAAI;QACJ,QAAQ;QACR,WAAW;KACZ,CAAC;IAEF,MAAM,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAEtC,GAAG,CAAC,2BAA2B,GAAG,sBAAsB,CAAC,CAAC;IAE1D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Project instructions loader for @orbitpanel/cli.
3
+ *
4
+ * Loads optional .orbit/instructions.md files that provide
5
+ * AI/UX context for the project. NOT a source of truth —
6
+ * only supplementary information.
7
+ */
8
+ export declare const INSTRUCTIONS_FILENAME = "instructions.md";
9
+ /** File I/O interface — overridable for testing. */
10
+ export interface InstructionsIO {
11
+ read(path: string): Promise<string>;
12
+ exists(path: string): Promise<boolean>;
13
+ }
14
+ /**
15
+ * Load instructions.md from the .orbit/ directory.
16
+ * Returns the content as a string, or null if not found.
17
+ */
18
+ export declare function loadInstructions(manifestDir: string, io?: InstructionsIO): Promise<string | null>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Project instructions loader for @orbitpanel/cli.
3
+ *
4
+ * Loads optional .orbit/instructions.md files that provide
5
+ * AI/UX context for the project. NOT a source of truth —
6
+ * only supplementary information.
7
+ */
8
+ import { join } from 'node:path';
9
+ import { readFile, access } from 'node:fs/promises';
10
+ import { MANIFEST_DIR } from './manifest.js';
11
+ export const INSTRUCTIONS_FILENAME = 'instructions.md';
12
+ const defaultIO = {
13
+ read: (path) => readFile(path, 'utf-8'),
14
+ exists: async (path) => {
15
+ try {
16
+ await access(path);
17
+ return true;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ },
23
+ };
24
+ /**
25
+ * Load instructions.md from the .orbit/ directory.
26
+ * Returns the content as a string, or null if not found.
27
+ */
28
+ export async function loadInstructions(manifestDir, io = defaultIO) {
29
+ try {
30
+ const path = join(manifestDir, MANIFEST_DIR, INSTRUCTIONS_FILENAME);
31
+ return await io.read(path);
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ //# sourceMappingURL=instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/lib/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAQvD,MAAM,SAAS,GAAmB;IAChC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;YAAC,OAAO,IAAI,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,OAAO,KAAK,CAAC;QAAC,CAAC;IAClE,CAAC;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,KAAqB,SAAS;IAE9B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,EAAE,qBAAqB,CAAC,CAAC;QACpE,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Project manifest management for @orbitpanel/cli.
3
+ *
4
+ * Handles .orbit/project.json discovery, validation, and persistence.
5
+ * Supports backward compatibility with legacy .orbit.json format.
6
+ *
7
+ * SEPARATION OF CONCERNS:
8
+ * - This module handles ONLY project identity (manifest)
9
+ * - Instructions (AI/UX context) are in instructions.ts
10
+ * - Environment detection is in environment.ts
11
+ */
12
+ import type { ProjectManifest, ManifestValidationResult, SiteLink } from '../types.js';
13
+ export declare const MANIFEST_DIR = ".orbit";
14
+ export declare const MANIFEST_FILENAME = "project.json";
15
+ export declare const MANIFEST_PATH = ".orbit/project.json";
16
+ export declare const LEGACY_FILENAME = ".orbit.json";
17
+ export declare const MAX_TRAVERSAL_DEPTH = 10;
18
+ /** File I/O interface — overridable for testing. */
19
+ export interface ManifestIO {
20
+ read(path: string): Promise<string>;
21
+ write(path: string, data: string): Promise<void>;
22
+ exists(path: string): Promise<boolean>;
23
+ mkdir(path: string): Promise<void>;
24
+ }
25
+ export declare const defaultManifestIO: ManifestIO;
26
+ /** Validate a parsed manifest object. Returns validation result. */
27
+ export declare function validateManifest(data: unknown): Omit<ManifestValidationResult, 'manifestDir' | 'legacy'>;
28
+ /**
29
+ * Find a project manifest by walking up the directory tree.
30
+ * Checks for .orbit/project.json first, then .orbit.json (legacy).
31
+ */
32
+ export declare function findManifest(startDir: string, io?: ManifestIO): Promise<ManifestValidationResult>;
33
+ /** Load manifest from a specific directory (no parent traversal). */
34
+ export declare function loadManifest(dir: string, io?: ManifestIO): Promise<ManifestValidationResult>;
35
+ /** Save manifest to .orbit/project.json. Creates .orbit/ directory if needed. */
36
+ export declare function saveManifest(dir: string, manifest: ProjectManifest, io?: ManifestIO): Promise<void>;
37
+ /** Convert a legacy SiteLink to a ProjectManifest. */
38
+ export declare function migrateFromLegacy(legacy: SiteLink): ProjectManifest;
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Project manifest management for @orbitpanel/cli.
3
+ *
4
+ * Handles .orbit/project.json discovery, validation, and persistence.
5
+ * Supports backward compatibility with legacy .orbit.json format.
6
+ *
7
+ * SEPARATION OF CONCERNS:
8
+ * - This module handles ONLY project identity (manifest)
9
+ * - Instructions (AI/UX context) are in instructions.ts
10
+ * - Environment detection is in environment.ts
11
+ */
12
+ import { join, dirname, resolve } from 'node:path';
13
+ import { readFile, writeFile, mkdir, access } from 'node:fs/promises';
14
+ // ─── Constants ────────────────────────────────────────────────────
15
+ export const MANIFEST_DIR = '.orbit';
16
+ export const MANIFEST_FILENAME = 'project.json';
17
+ export const MANIFEST_PATH = `${MANIFEST_DIR}/${MANIFEST_FILENAME}`;
18
+ export const LEGACY_FILENAME = '.orbit.json';
19
+ export const MAX_TRAVERSAL_DEPTH = 10;
20
+ const VALID_VERSIONS = [1];
21
+ const VALID_PLATFORMS = ['wordpress', 'prestashop', 'custom'];
22
+ const VALID_ENVIRONMENTS = ['local', 'dev', 'staging', 'production'];
23
+ const KNOWN_FIELDS = new Set([
24
+ 'version', 'name', 'platform', 'environment', 'linkedSiteId', 'root',
25
+ ]);
26
+ export const defaultManifestIO = {
27
+ read: (path) => readFile(path, 'utf-8'),
28
+ write: (path, data) => writeFile(path, data, { encoding: 'utf-8', mode: 0o644 }),
29
+ exists: async (path) => {
30
+ try {
31
+ await access(path);
32
+ return true;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ },
38
+ mkdir: async (path) => { await mkdir(path, { recursive: true }); },
39
+ };
40
+ // ─── Validation ───────────────────────────────────────────────────
41
+ /** Validate a parsed manifest object. Returns validation result. */
42
+ export function validateManifest(data) {
43
+ const errors = [];
44
+ const warnings = [];
45
+ if (data === null || data === undefined || typeof data !== 'object') {
46
+ return { valid: false, manifest: null, errors: ['Manifest deve essere un oggetto JSON'], warnings };
47
+ }
48
+ const obj = data;
49
+ // version (required, must be supported)
50
+ if (obj.version === undefined || obj.version === null) {
51
+ errors.push('Campo "version" obbligatorio');
52
+ }
53
+ else if (!VALID_VERSIONS.includes(obj.version)) {
54
+ errors.push(`Campo "version" non supportato: ${obj.version}. Valori: ${VALID_VERSIONS.join(', ')}`);
55
+ }
56
+ // name (required, non-empty string)
57
+ if (obj.name === undefined || obj.name === null) {
58
+ errors.push('Campo "name" obbligatorio');
59
+ }
60
+ else if (typeof obj.name !== 'string' || obj.name.trim() === '') {
61
+ errors.push('Campo "name" deve essere una stringa non vuota');
62
+ }
63
+ // platform (required, must be valid)
64
+ if (obj.platform === undefined || obj.platform === null) {
65
+ errors.push('Campo "platform" obbligatorio');
66
+ }
67
+ else if (!VALID_PLATFORMS.includes(obj.platform)) {
68
+ errors.push(`Campo "platform" non valido: ${obj.platform}. Valori: ${VALID_PLATFORMS.join(', ')}`);
69
+ }
70
+ // environment (required, must be valid)
71
+ if (obj.environment === undefined || obj.environment === null) {
72
+ errors.push('Campo "environment" obbligatorio');
73
+ }
74
+ else if (!VALID_ENVIRONMENTS.includes(obj.environment)) {
75
+ errors.push(`Campo "environment" non valido: ${obj.environment}. Valori: ${VALID_ENVIRONMENTS.join(', ')}`);
76
+ }
77
+ // Warn on unknown fields
78
+ for (const key of Object.keys(obj)) {
79
+ if (!KNOWN_FIELDS.has(key)) {
80
+ warnings.push(`Campo sconosciuto "${key}" — verra ignorato`);
81
+ }
82
+ }
83
+ if (errors.length > 0) {
84
+ return { valid: false, manifest: null, errors, warnings };
85
+ }
86
+ const manifest = {
87
+ version: obj.version,
88
+ name: obj.name.trim(),
89
+ platform: obj.platform,
90
+ environment: obj.environment,
91
+ ...(obj.linkedSiteId !== undefined && { linkedSiteId: String(obj.linkedSiteId) }),
92
+ ...(obj.root !== undefined && { root: String(obj.root) }),
93
+ };
94
+ return { valid: true, manifest, errors: [], warnings };
95
+ }
96
+ // ─── Find Manifest (walk-up) ──────────────────────────────────────
97
+ /**
98
+ * Find a project manifest by walking up the directory tree.
99
+ * Checks for .orbit/project.json first, then .orbit.json (legacy).
100
+ */
101
+ export async function findManifest(startDir, io = defaultManifestIO) {
102
+ const notFound = {
103
+ valid: false,
104
+ manifest: null,
105
+ errors: [],
106
+ warnings: [],
107
+ manifestDir: null,
108
+ legacy: false,
109
+ };
110
+ let currentDir = resolve(startDir);
111
+ let depth = 0;
112
+ while (depth < MAX_TRAVERSAL_DEPTH) {
113
+ // 1. Check .orbit/project.json (preferred)
114
+ const manifestPath = join(currentDir, MANIFEST_DIR, MANIFEST_FILENAME);
115
+ if (await io.exists(manifestPath)) {
116
+ return readAndValidateManifest(manifestPath, currentDir, false, io);
117
+ }
118
+ // 2. Check .orbit.json (legacy fallback) — only in current dir, not parents
119
+ if (depth === 0) {
120
+ // Also check parents for legacy
121
+ }
122
+ const legacyPath = join(currentDir, LEGACY_FILENAME);
123
+ if (await io.exists(legacyPath)) {
124
+ return readAndValidateLegacy(legacyPath, currentDir, io);
125
+ }
126
+ // Go up one level
127
+ const parentDir = dirname(currentDir);
128
+ if (parentDir === currentDir) {
129
+ // Reached root
130
+ break;
131
+ }
132
+ currentDir = parentDir;
133
+ depth++;
134
+ }
135
+ return notFound;
136
+ }
137
+ /** Read and validate a .orbit/project.json file. */
138
+ async function readAndValidateManifest(filePath, dir, legacy, io) {
139
+ try {
140
+ const raw = await io.read(filePath);
141
+ const parsed = JSON.parse(raw);
142
+ const validation = validateManifest(parsed);
143
+ return {
144
+ ...validation,
145
+ manifestDir: dir,
146
+ legacy,
147
+ };
148
+ }
149
+ catch (error) {
150
+ return {
151
+ valid: false,
152
+ manifest: null,
153
+ errors: [`Errore lettura manifest: ${error instanceof Error ? error.message : String(error)}`],
154
+ warnings: [],
155
+ manifestDir: dir,
156
+ legacy,
157
+ };
158
+ }
159
+ }
160
+ /** Read a legacy .orbit.json and convert to manifest format. */
161
+ async function readAndValidateLegacy(filePath, dir, io) {
162
+ try {
163
+ const raw = await io.read(filePath);
164
+ const parsed = JSON.parse(raw);
165
+ const manifest = migrateFromLegacy(parsed);
166
+ const validation = validateManifest(manifest);
167
+ return {
168
+ ...validation,
169
+ manifestDir: dir,
170
+ legacy: true,
171
+ };
172
+ }
173
+ catch (error) {
174
+ return {
175
+ valid: false,
176
+ manifest: null,
177
+ errors: [`Errore lettura .orbit.json legacy: ${error instanceof Error ? error.message : String(error)}`],
178
+ warnings: [],
179
+ manifestDir: dir,
180
+ legacy: true,
181
+ };
182
+ }
183
+ }
184
+ // ─── Load Manifest (no walk-up) ───────────────────────────────────
185
+ /** Load manifest from a specific directory (no parent traversal). */
186
+ export async function loadManifest(dir, io = defaultManifestIO) {
187
+ const manifestPath = join(dir, MANIFEST_DIR, MANIFEST_FILENAME);
188
+ if (await io.exists(manifestPath)) {
189
+ return readAndValidateManifest(manifestPath, dir, false, io);
190
+ }
191
+ return {
192
+ valid: false,
193
+ manifest: null,
194
+ errors: [],
195
+ warnings: [],
196
+ manifestDir: null,
197
+ legacy: false,
198
+ };
199
+ }
200
+ // ─── Save Manifest ────────────────────────────────────────────────
201
+ /** Save manifest to .orbit/project.json. Creates .orbit/ directory if needed. */
202
+ export async function saveManifest(dir, manifest, io = defaultManifestIO) {
203
+ const orbitDir = join(dir, MANIFEST_DIR);
204
+ await io.mkdir(orbitDir);
205
+ await io.write(join(orbitDir, MANIFEST_FILENAME), JSON.stringify(manifest, null, 2) + '\n');
206
+ }
207
+ // ─── Legacy Migration ─────────────────────────────────────────────
208
+ /** Map a legacy environment string to a valid EnvironmentType. */
209
+ function mapLegacyEnvironment(env) {
210
+ if (!env)
211
+ return 'local';
212
+ const lower = env.toLowerCase();
213
+ if (lower.includes('local') || lower.includes('dev-local'))
214
+ return 'local';
215
+ if (lower === 'dev' || lower === 'development')
216
+ return 'dev';
217
+ if (lower.includes('staging') || lower.includes('stage'))
218
+ return 'staging';
219
+ if (lower.includes('prod') || lower.includes('live'))
220
+ return 'production';
221
+ // If the string is exactly a valid value, use it
222
+ if (VALID_ENVIRONMENTS.includes(lower))
223
+ return lower;
224
+ return 'local';
225
+ }
226
+ /** Convert a legacy SiteLink to a ProjectManifest. */
227
+ export function migrateFromLegacy(legacy) {
228
+ return {
229
+ version: 1,
230
+ name: legacy.name || legacy.orbit_site_id,
231
+ platform: legacy.platform,
232
+ environment: mapLegacyEnvironment(legacy.environment),
233
+ linkedSiteId: legacy.orbit_site_id,
234
+ ...(legacy.final_url !== undefined && { root: '.' }),
235
+ };
236
+ }
237
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/lib/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAUtE,qEAAqE;AAErE,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AACrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAChD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,YAAY,IAAI,iBAAiB,EAAE,CAAC;AACpE,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,MAAM,cAAc,GAAsB,CAAC,CAAC,CAAC,CAAC;AAC9C,MAAM,eAAe,GAAmB,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AAC9E,MAAM,kBAAkB,GAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AACxF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM;CACrE,CAAC,CAAC;AAYH,MAAM,CAAC,MAAM,iBAAiB,GAAe;IAC3C,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvC,KAAK,EAA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AC,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3E,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,YAAY,CAAC;IAC1E,iDAAiD;IACjD,IAAI,kBAAkB,CAAC,QAAQ,CAAC,KAAwB,CAAC;QAAE,OAAO,KAAwB,CAAC;IAC3F,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,iBAAiB,CAAC,MAAgB;IAChD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,aAAa;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,WAAW,EAAE,oBAAoB,CAAC,MAAM,CAAC,WAAW,CAAC;QACrD,YAAY,EAAE,MAAM,CAAC,aAAa;QAClC,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;KACrD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * In-memory prompt history for @orbitpanel/cli.
3
+ *
4
+ * Pure logic — no UI, no persistence.
5
+ * Supports draft preservation when navigating history.
6
+ *
7
+ * Usage:
8
+ * const h = createPromptHistory();
9
+ * h.push("ciao");
10
+ * h.push("/doctor");
11
+ * h.up("current draft") → "/doctor"
12
+ * h.up("/doctor") → "ciao"
13
+ * h.down("ciao") → "/doctor"
14
+ * h.down("/doctor") → "current draft" (restored)
15
+ */
16
+ export interface PromptHistory {
17
+ /** Add a submitted prompt to history. Resets navigation. */
18
+ push(text: string): void;
19
+ /** Navigate up (older). Returns previous entry or current text if at top. */
20
+ up(currentText: string): string;
21
+ /** Navigate down (newer). Returns next entry or draft if at bottom. */
22
+ down(currentText: string): string;
23
+ /** Whether currently navigating history (not at bottom). */
24
+ isNavigating(): boolean;
25
+ /** Reset navigation to bottom (current input). */
26
+ reset(): void;
27
+ /** Get all history entries (oldest first). */
28
+ getEntries(): string[];
29
+ }
30
+ export declare function createPromptHistory(maxSize?: number): PromptHistory;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * In-memory prompt history for @orbitpanel/cli.
3
+ *
4
+ * Pure logic — no UI, no persistence.
5
+ * Supports draft preservation when navigating history.
6
+ *
7
+ * Usage:
8
+ * const h = createPromptHistory();
9
+ * h.push("ciao");
10
+ * h.push("/doctor");
11
+ * h.up("current draft") → "/doctor"
12
+ * h.up("/doctor") → "ciao"
13
+ * h.down("ciao") → "/doctor"
14
+ * h.down("/doctor") → "current draft" (restored)
15
+ */
16
+ export function createPromptHistory(maxSize = 100) {
17
+ const entries = [];
18
+ let idx = -1; // -1 = not navigating (at bottom/current input)
19
+ let draft = ''; // preserved draft when navigating
20
+ return {
21
+ push(text) {
22
+ // Don't add duplicates at the end
23
+ if (entries.length > 0 && entries[entries.length - 1] === text) {
24
+ idx = -1;
25
+ draft = '';
26
+ return;
27
+ }
28
+ entries.push(text);
29
+ // Trim to max size
30
+ if (entries.length > maxSize) {
31
+ entries.splice(0, entries.length - maxSize);
32
+ }
33
+ idx = -1;
34
+ draft = '';
35
+ },
36
+ up(currentText) {
37
+ if (entries.length === 0)
38
+ return currentText;
39
+ if (idx === -1) {
40
+ // Starting navigation — save current text as draft
41
+ draft = currentText;
42
+ idx = entries.length - 1;
43
+ return entries[idx];
44
+ }
45
+ if (idx > 0) {
46
+ idx--;
47
+ return entries[idx];
48
+ }
49
+ // Already at top — stay
50
+ return entries[idx];
51
+ },
52
+ down(currentText) {
53
+ if (idx === -1)
54
+ return currentText; // not navigating
55
+ if (idx < entries.length - 1) {
56
+ idx++;
57
+ return entries[idx];
58
+ }
59
+ // At bottom of history — restore draft
60
+ idx = -1;
61
+ return draft;
62
+ },
63
+ isNavigating() {
64
+ return idx !== -1;
65
+ },
66
+ reset() {
67
+ idx = -1;
68
+ draft = '';
69
+ },
70
+ getEntries() {
71
+ return [...entries];
72
+ },
73
+ };
74
+ }
75
+ //# sourceMappingURL=prompt-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-history.js","sourceRoot":"","sources":["../../src/lib/prompt-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH,MAAM,UAAU,mBAAmB,CAAC,OAAO,GAAG,GAAG;IAC/C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,gDAAgD;IAC9D,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC,kCAAkC;IAElD,OAAO;QACL,IAAI,CAAC,IAAY;YACf,kCAAkC;YAClC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC/D,GAAG,GAAG,CAAC,CAAC,CAAC;gBACT,KAAK,GAAG,EAAE,CAAC;gBACX,OAAO;YACT,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,mBAAmB;YACnB,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;gBAC7B,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;YAC9C,CAAC;YACD,GAAG,GAAG,CAAC,CAAC,CAAC;YACT,KAAK,GAAG,EAAE,CAAC;QACb,CAAC;QAED,EAAE,CAAC,WAAmB;YACpB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,WAAW,CAAC;YAE7C,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;gBACf,mDAAmD;gBACnD,KAAK,GAAG,WAAW,CAAC;gBACpB,GAAG,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;gBACzB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