@principal-ai/principal-studio-cli 0.35.3

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 (184) hide show
  1. package/README.md +172 -0
  2. package/dist/commands/agent-session.d.ts +3 -0
  3. package/dist/commands/agent-session.d.ts.map +1 -0
  4. package/dist/commands/agent-session.js +67 -0
  5. package/dist/commands/agent-sessions.d.ts +11 -0
  6. package/dist/commands/agent-sessions.d.ts.map +1 -0
  7. package/dist/commands/agent-sessions.js +39 -0
  8. package/dist/commands/auxiliary/index.d.ts +3 -0
  9. package/dist/commands/auxiliary/index.d.ts.map +1 -0
  10. package/dist/commands/auxiliary/index.js +9 -0
  11. package/dist/commands/auxiliary/validate.d.ts +3 -0
  12. package/dist/commands/auxiliary/validate.d.ts.map +1 -0
  13. package/dist/commands/auxiliary/validate.js +123 -0
  14. package/dist/commands/collector/check.d.ts +6 -0
  15. package/dist/commands/collector/check.d.ts.map +1 -0
  16. package/dist/commands/collector/check.js +153 -0
  17. package/dist/commands/collector/diagnose.d.ts +6 -0
  18. package/dist/commands/collector/diagnose.d.ts.map +1 -0
  19. package/dist/commands/collector/diagnose.js +229 -0
  20. package/dist/commands/collector/index.d.ts +6 -0
  21. package/dist/commands/collector/index.d.ts.map +1 -0
  22. package/dist/commands/collector/index.js +16 -0
  23. package/dist/commands/collector/status.d.ts +6 -0
  24. package/dist/commands/collector/status.d.ts.map +1 -0
  25. package/dist/commands/collector/status.js +77 -0
  26. package/dist/commands/collector/utils.d.ts +92 -0
  27. package/dist/commands/collector/utils.d.ts.map +1 -0
  28. package/dist/commands/collector/utils.js +154 -0
  29. package/dist/commands/coverage.d.ts +9 -0
  30. package/dist/commands/coverage.d.ts.map +1 -0
  31. package/dist/commands/coverage.js +252 -0
  32. package/dist/commands/create.d.ts +6 -0
  33. package/dist/commands/create.d.ts.map +1 -0
  34. package/dist/commands/create.js +50 -0
  35. package/dist/commands/events/index.d.ts +3 -0
  36. package/dist/commands/events/index.d.ts.map +1 -0
  37. package/dist/commands/events/index.js +9 -0
  38. package/dist/commands/events/validate.d.ts +3 -0
  39. package/dist/commands/events/validate.d.ts.map +1 -0
  40. package/dist/commands/events/validate.js +124 -0
  41. package/dist/commands/formats.d.ts +6 -0
  42. package/dist/commands/formats.d.ts.map +1 -0
  43. package/dist/commands/formats.js +1118 -0
  44. package/dist/commands/hooks.d.ts +9 -0
  45. package/dist/commands/hooks.d.ts.map +1 -0
  46. package/dist/commands/hooks.js +295 -0
  47. package/dist/commands/inbox.d.ts +13 -0
  48. package/dist/commands/inbox.d.ts.map +1 -0
  49. package/dist/commands/inbox.js +179 -0
  50. package/dist/commands/init.d.ts +6 -0
  51. package/dist/commands/init.d.ts.map +1 -0
  52. package/dist/commands/init.js +220 -0
  53. package/dist/commands/lint.d.ts +11 -0
  54. package/dist/commands/lint.d.ts.map +1 -0
  55. package/dist/commands/lint.js +71 -0
  56. package/dist/commands/list.d.ts +6 -0
  57. package/dist/commands/list.d.ts.map +1 -0
  58. package/dist/commands/list.js +78 -0
  59. package/dist/commands/migrate-nodes.d.ts +9 -0
  60. package/dist/commands/migrate-nodes.d.ts.map +1 -0
  61. package/dist/commands/migrate-nodes.js +363 -0
  62. package/dist/commands/migrate-scopes-to-canvas.d.ts +3 -0
  63. package/dist/commands/migrate-scopes-to-canvas.d.ts.map +1 -0
  64. package/dist/commands/migrate-scopes-to-canvas.js +143 -0
  65. package/dist/commands/migration.d.ts +6 -0
  66. package/dist/commands/migration.d.ts.map +1 -0
  67. package/dist/commands/migration.js +247 -0
  68. package/dist/commands/open-studio.d.ts +10 -0
  69. package/dist/commands/open-studio.d.ts.map +1 -0
  70. package/dist/commands/open-studio.js +32 -0
  71. package/dist/commands/opencode/fetch.d.ts +3 -0
  72. package/dist/commands/opencode/fetch.d.ts.map +1 -0
  73. package/dist/commands/opencode/fetch.js +25 -0
  74. package/dist/commands/opencode/index.d.ts +3 -0
  75. package/dist/commands/opencode/index.d.ts.map +1 -0
  76. package/dist/commands/opencode/index.js +11 -0
  77. package/dist/commands/opencode/list-sessions.d.ts +3 -0
  78. package/dist/commands/opencode/list-sessions.d.ts.map +1 -0
  79. package/dist/commands/opencode/list-sessions.js +20 -0
  80. package/dist/commands/repo.d.ts +18 -0
  81. package/dist/commands/repo.d.ts.map +1 -0
  82. package/dist/commands/repo.js +233 -0
  83. package/dist/commands/schema.d.ts +6 -0
  84. package/dist/commands/schema.d.ts.map +1 -0
  85. package/dist/commands/schema.js +367 -0
  86. package/dist/commands/scopes/index.d.ts +3 -0
  87. package/dist/commands/scopes/index.d.ts.map +1 -0
  88. package/dist/commands/scopes/index.js +9 -0
  89. package/dist/commands/scopes/validate.d.ts +3 -0
  90. package/dist/commands/scopes/validate.d.ts.map +1 -0
  91. package/dist/commands/scopes/validate.js +187 -0
  92. package/dist/commands/setup.d.ts +6 -0
  93. package/dist/commands/setup.d.ts.map +1 -0
  94. package/dist/commands/setup.js +406 -0
  95. package/dist/commands/starred-collections.d.ts +12 -0
  96. package/dist/commands/starred-collections.d.ts.map +1 -0
  97. package/dist/commands/starred-collections.js +310 -0
  98. package/dist/commands/subsystem-model.d.ts +11 -0
  99. package/dist/commands/subsystem-model.d.ts.map +1 -0
  100. package/dist/commands/subsystem-model.js +249 -0
  101. package/dist/commands/topic.d.ts +15 -0
  102. package/dist/commands/topic.d.ts.map +1 -0
  103. package/dist/commands/topic.js +683 -0
  104. package/dist/commands/tour.d.ts +23 -0
  105. package/dist/commands/tour.d.ts.map +1 -0
  106. package/dist/commands/tour.js +783 -0
  107. package/dist/commands/trace/flow.d.ts +6 -0
  108. package/dist/commands/trace/flow.d.ts.map +1 -0
  109. package/dist/commands/trace/flow.js +158 -0
  110. package/dist/commands/trace/index.d.ts +6 -0
  111. package/dist/commands/trace/index.d.ts.map +1 -0
  112. package/dist/commands/trace/index.js +20 -0
  113. package/dist/commands/trace/inspect.d.ts +6 -0
  114. package/dist/commands/trace/inspect.d.ts.map +1 -0
  115. package/dist/commands/trace/inspect.js +187 -0
  116. package/dist/commands/trace/list.d.ts +6 -0
  117. package/dist/commands/trace/list.d.ts.map +1 -0
  118. package/dist/commands/trace/list.js +145 -0
  119. package/dist/commands/trace/registrations.d.ts +6 -0
  120. package/dist/commands/trace/registrations.d.ts.map +1 -0
  121. package/dist/commands/trace/registrations.js +81 -0
  122. package/dist/commands/trace/validate.d.ts +6 -0
  123. package/dist/commands/trace/validate.d.ts.map +1 -0
  124. package/dist/commands/trace/validate.js +276 -0
  125. package/dist/commands/trail.d.ts +36 -0
  126. package/dist/commands/trail.d.ts.map +1 -0
  127. package/dist/commands/trail.js +622 -0
  128. package/dist/commands/validate.d.ts +12 -0
  129. package/dist/commands/validate.d.ts.map +1 -0
  130. package/dist/commands/validate.js +3334 -0
  131. package/dist/commands/workflow/implementation.d.ts +3 -0
  132. package/dist/commands/workflow/implementation.d.ts.map +1 -0
  133. package/dist/commands/workflow/implementation.js +51 -0
  134. package/dist/commands/workflow/index.d.ts +3 -0
  135. package/dist/commands/workflow/index.d.ts.map +1 -0
  136. package/dist/commands/workflow/index.js +19 -0
  137. package/dist/commands/workflow/inspect.d.ts +3 -0
  138. package/dist/commands/workflow/inspect.d.ts.map +1 -0
  139. package/dist/commands/workflow/inspect.js +123 -0
  140. package/dist/commands/workflow/list.d.ts +3 -0
  141. package/dist/commands/workflow/list.d.ts.map +1 -0
  142. package/dist/commands/workflow/list.js +95 -0
  143. package/dist/commands/workflow/render.d.ts +3 -0
  144. package/dist/commands/workflow/render.d.ts.map +1 -0
  145. package/dist/commands/workflow/render.js +88 -0
  146. package/dist/commands/workflow/test.d.ts +3 -0
  147. package/dist/commands/workflow/test.d.ts.map +1 -0
  148. package/dist/commands/workflow/test.js +141 -0
  149. package/dist/commands/workflow/utils.d.ts +49 -0
  150. package/dist/commands/workflow/utils.d.ts.map +1 -0
  151. package/dist/commands/workflow/utils.js +164 -0
  152. package/dist/commands/workflow/validate.d.ts +3 -0
  153. package/dist/commands/workflow/validate.d.ts.map +1 -0
  154. package/dist/commands/workflow/validate.js +344 -0
  155. package/dist/file-utils.d.ts +15 -0
  156. package/dist/file-utils.d.ts.map +1 -0
  157. package/dist/file-utils.js +29 -0
  158. package/dist/index.cjs +285718 -0
  159. package/dist/index.cjs.map +7 -0
  160. package/dist/index.d.ts +8 -0
  161. package/dist/index.d.ts.map +1 -0
  162. package/dist/index.js +81 -0
  163. package/dist/lib/bridge-ipc.d.ts +29 -0
  164. package/dist/lib/bridge-ipc.d.ts.map +1 -0
  165. package/dist/lib/bridge-ipc.js +128 -0
  166. package/dist/lib/github-user.d.ts +17 -0
  167. package/dist/lib/github-user.d.ts.map +1 -0
  168. package/dist/lib/github-user.js +53 -0
  169. package/dist/lib/open-url.d.ts +11 -0
  170. package/dist/lib/open-url.d.ts.map +1 -0
  171. package/dist/lib/open-url.js +45 -0
  172. package/dist/lib/subsystem-model-store.d.ts +74 -0
  173. package/dist/lib/subsystem-model-store.d.ts.map +1 -0
  174. package/dist/lib/subsystem-model-store.js +292 -0
  175. package/dist/lib/tour-cache.d.ts +26 -0
  176. package/dist/lib/tour-cache.d.ts.map +1 -0
  177. package/dist/lib/tour-cache.js +46 -0
  178. package/dist/lib/trail-cache.d.ts +40 -0
  179. package/dist/lib/trail-cache.d.ts.map +1 -0
  180. package/dist/lib/trail-cache.js +97 -0
  181. package/dist/lib/viewer-ipc.d.ts +44 -0
  182. package/dist/lib/viewer-ipc.d.ts.map +1 -0
  183. package/dist/lib/viewer-ipc.js +68 -0
  184. package/package.json +68 -0
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Init command - Initialize a .principal-views folder with template files and linting setup
3
+ */
4
+ import { Command } from 'commander';
5
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, chmodSync } from 'node:fs';
6
+ import { join } from 'node:path';
7
+ import { execSync } from 'node:child_process';
8
+ import chalk from 'chalk';
9
+ const TEMPLATE_CANVAS = {
10
+ nodes: [],
11
+ edges: [],
12
+ };
13
+ const HUSKY_PRE_COMMIT = `# Run principal view linting on staged .principal-views files
14
+ npx @principal-ai/principal-studio-cli lint --quiet
15
+ `;
16
+ /**
17
+ * Check if we're in a git repository
18
+ */
19
+ function isGitRepo() {
20
+ try {
21
+ execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
22
+ return true;
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ /**
29
+ * Get the git root directory
30
+ */
31
+ function getGitRoot() {
32
+ try {
33
+ return execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
34
+ }
35
+ catch {
36
+ return null;
37
+ }
38
+ }
39
+ /**
40
+ * Check if husky is already installed
41
+ */
42
+ function isHuskyInstalled(gitRoot) {
43
+ return existsSync(join(gitRoot, '.husky'));
44
+ }
45
+ /**
46
+ * Detect package manager
47
+ */
48
+ function detectPackageManager() {
49
+ if (existsSync('bun.lockb'))
50
+ return 'bun';
51
+ if (existsSync('pnpm-lock.yaml'))
52
+ return 'pnpm';
53
+ if (existsSync('yarn.lock'))
54
+ return 'yarn';
55
+ return 'npm';
56
+ }
57
+ export function createInitCommand() {
58
+ const command = new Command('init');
59
+ command
60
+ .description('Initialize a .principal-views folder with template files and linting setup')
61
+ .option('-f, --force', 'Overwrite existing files')
62
+ .option('-n, --name <name>', 'Name for the canvas file', 'architecture')
63
+ .option('--no-husky', 'Skip Husky pre-commit hook setup')
64
+ .action(async (options) => {
65
+ try {
66
+ const cwd = process.cwd();
67
+ const principalViewsDir = join(cwd, '.principal-views');
68
+ const canvasFile = join(principalViewsDir, `${options.name}.canvas`);
69
+ const libraryFile = join(principalViewsDir, 'library.yaml');
70
+ // Check if .principal-views directory exists
71
+ if (!existsSync(principalViewsDir)) {
72
+ mkdirSync(principalViewsDir, { recursive: true });
73
+ console.log(chalk.green(`Created directory: .principal-views/`));
74
+ }
75
+ // Create canvas file
76
+ if (existsSync(canvasFile) && !options.force) {
77
+ console.log(chalk.yellow(`Canvas file already exists: .principal-views/${options.name}.canvas`));
78
+ }
79
+ else {
80
+ writeFileSync(canvasFile, JSON.stringify(TEMPLATE_CANVAS, null, 2));
81
+ console.log(chalk.green(`Created canvas file: .principal-views/${options.name}.canvas`));
82
+ }
83
+ // Create library file
84
+ if (existsSync(libraryFile) && !options.force) {
85
+ console.log(chalk.yellow(`Library file already exists: .principal-views/library.yaml`));
86
+ }
87
+ else {
88
+ const libraryYaml = `# Principal View Component Library
89
+ version: "1.0.0"
90
+ name: "Component Library"
91
+ description: "Component library for Principal View visualizations"
92
+
93
+ # Service resource registry
94
+ # Define all services in this repository with their OTEL resource attributes
95
+ # Each service configures its own resources at runtime, but declaring them here provides:
96
+ # - Service documentation/registry
97
+ # - Expected resource schema for validation
98
+ # - Dev workspace trace routing
99
+ #
100
+ # Example:
101
+ # resources:
102
+ # my-service:
103
+ # service.name: "my-service"
104
+ # service.version: "1.0.0"
105
+ # deployment.environment: "development"
106
+ #
107
+ resources: {}
108
+
109
+ nodeComponents: {}
110
+
111
+ edgeComponents: {}
112
+ `;
113
+ writeFileSync(libraryFile, libraryYaml);
114
+ console.log(chalk.green(`Created library file: .principal-views/library.yaml`));
115
+ }
116
+ // Set up Husky pre-commit hook
117
+ let huskySetup = false;
118
+ if (options.husky !== false) {
119
+ if (!isGitRepo()) {
120
+ console.log(chalk.yellow(`Skipping Husky setup: not a git repository`));
121
+ }
122
+ else {
123
+ const gitRoot = getGitRoot();
124
+ if (!gitRoot) {
125
+ console.log(chalk.yellow(`Skipping Husky setup: could not find git root`));
126
+ }
127
+ else {
128
+ const huskyDir = join(gitRoot, '.husky');
129
+ const preCommitFile = join(huskyDir, 'pre-commit');
130
+ if (isHuskyInstalled(gitRoot)) {
131
+ // Husky is already installed, just add/update pre-commit hook
132
+ if (existsSync(preCommitFile)) {
133
+ // Check if our hook is already in the file
134
+ const existingContent = readFileSync(preCommitFile, 'utf8');
135
+ if (existingContent.includes('principal-view-cli lint')) {
136
+ console.log(chalk.yellow(`Husky pre-commit hook already includes principal view linting`));
137
+ }
138
+ else {
139
+ // Append our lint command to existing pre-commit
140
+ const updatedContent = existingContent.trimEnd() +
141
+ '\n\n# Run principal view linting\nnpx @principal-ai/principal-studio-cli lint --quiet\n';
142
+ writeFileSync(preCommitFile, updatedContent);
143
+ console.log(chalk.green(`Updated Husky pre-commit hook with principal view linting`));
144
+ huskySetup = true;
145
+ }
146
+ }
147
+ else {
148
+ // Create new pre-commit hook
149
+ writeFileSync(preCommitFile, HUSKY_PRE_COMMIT);
150
+ chmodSync(preCommitFile, '755');
151
+ console.log(chalk.green(`Created Husky pre-commit hook`));
152
+ huskySetup = true;
153
+ }
154
+ }
155
+ else {
156
+ // Husky is not installed, try to install it
157
+ const pm = detectPackageManager();
158
+ const packageJsonPath = join(gitRoot, 'package.json');
159
+ if (!existsSync(packageJsonPath)) {
160
+ console.log(chalk.yellow(`Skipping Husky setup: no package.json found`));
161
+ }
162
+ else {
163
+ console.log(chalk.dim(`Installing Husky...`));
164
+ try {
165
+ // Install husky as dev dependency
166
+ const installCmd = {
167
+ npm: 'npm install --save-dev husky',
168
+ yarn: 'yarn add --dev husky',
169
+ pnpm: 'pnpm add --save-dev husky',
170
+ bun: 'bun add --dev husky',
171
+ }[pm];
172
+ execSync(installCmd, { stdio: 'inherit', cwd: gitRoot });
173
+ // Initialize husky
174
+ execSync('npx husky init', { stdio: 'inherit', cwd: gitRoot });
175
+ // Write our pre-commit hook
176
+ writeFileSync(preCommitFile, HUSKY_PRE_COMMIT);
177
+ chmodSync(preCommitFile, '755');
178
+ console.log(chalk.green(`Installed Husky and created pre-commit hook`));
179
+ huskySetup = true;
180
+ }
181
+ catch (installError) {
182
+ console.log(chalk.yellow(`Could not install Husky automatically: ${installError.message}`));
183
+ console.log(chalk.dim(` You can install it manually: ${pm} add --dev husky && npx husky init`));
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ }
190
+ console.log('');
191
+ console.log(chalk.bold('Setup complete!'));
192
+ console.log('');
193
+ console.log(chalk.bold('Files created:'));
194
+ console.log(` • ${chalk.cyan('.principal-views/library.yaml')} - Component library definitions`);
195
+ console.log(` • ${chalk.cyan(`.principal-views/${options.name}.canvas`)} - Graph canvas file`);
196
+ if (huskySetup) {
197
+ console.log(` • ${chalk.cyan('.husky/pre-commit')} - Pre-commit hook`);
198
+ }
199
+ console.log('');
200
+ console.log(chalk.bold('Next steps:'));
201
+ console.log(` 1. Define components in ${chalk.cyan('.principal-views/library.yaml')}`);
202
+ console.log(` 2. Build your graph in ${chalk.cyan(`.principal-views/${options.name}.canvas`)}`);
203
+ console.log(` 3. Run ${chalk.cyan('npx @principal-ai/principal-studio-cli lint')} to validate your configuration`);
204
+ if (huskySetup) {
205
+ console.log(` 4. Commits will now automatically lint .principal-views files`);
206
+ }
207
+ console.log('');
208
+ console.log(chalk.bold('Commands:'));
209
+ console.log(` • ${chalk.cyan('npx @principal-ai/principal-studio-cli lint')} - Lint configuration files`);
210
+ console.log(` • ${chalk.cyan('npx @principal-ai/principal-studio-cli lint --json')} - Output lint results as JSON`);
211
+ console.log(` • ${chalk.cyan('npx @principal-ai/principal-studio-cli validate')} - Validate canvas files`);
212
+ console.log(` • ${chalk.cyan('npx @principal-ai/principal-studio-cli doctor')} - Check project setup`);
213
+ }
214
+ catch (error) {
215
+ console.error(chalk.red('Error:'), error.message);
216
+ process.exit(1);
217
+ }
218
+ });
219
+ return command;
220
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Lint command - DEPRECATED
3
+ *
4
+ * This command has been deprecated and now calls the `validate` command internally.
5
+ * Please use `validate` directly for all validation needs.
6
+ *
7
+ * @deprecated Use `validate` command instead
8
+ */
9
+ import { Command } from 'commander';
10
+ export declare function createLintCommand(): Command;
11
+ //# sourceMappingURL=lint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/commands/lint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,iBAAiB,IAAI,OAAO,CAsE3C"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Lint command - DEPRECATED
3
+ *
4
+ * This command has been deprecated and now calls the `validate` command internally.
5
+ * Please use `validate` directly for all validation needs.
6
+ *
7
+ * @deprecated Use `validate` command instead
8
+ */
9
+ import { Command } from 'commander';
10
+ import chalk from 'chalk';
11
+ import { spawn } from 'node:child_process';
12
+ export function createLintCommand() {
13
+ const command = new Command('lint');
14
+ command
15
+ .description('DEPRECATED: Use `validate` instead. Validates Principal View files.')
16
+ .argument('[files...]', 'Files or glob patterns to validate (defaults to .principal-views/**/*)')
17
+ .option('--library <path>', 'DEPRECATED: Path to component library file (ignored)')
18
+ .option('-q, --quiet', 'Only output errors')
19
+ .option('--json', 'Output results as JSON')
20
+ .option('--rule <rules...>', 'DEPRECATED: Only run specific rules (ignored)')
21
+ .option('--ignore-rule <rules...>', 'DEPRECATED: Skip specific rules (ignored)')
22
+ .action(async (files, options) => {
23
+ // Show deprecation warning (unless JSON output or quiet mode)
24
+ if (!options.json && !options.quiet) {
25
+ console.log(chalk.yellow('⚠️ The `lint` command is deprecated and will be removed in a future version.'));
26
+ console.log(chalk.yellow(' Please use `validate` instead.\n'));
27
+ }
28
+ // Warn about ignored options
29
+ if (!options.json && !options.quiet) {
30
+ const ignoredOptions = [];
31
+ if (options.library)
32
+ ignoredOptions.push('--library');
33
+ if (options.rule)
34
+ ignoredOptions.push('--rule');
35
+ if (options.ignoreRule)
36
+ ignoredOptions.push('--ignore-rule');
37
+ if (ignoredOptions.length > 0) {
38
+ console.log(chalk.dim(` Note: ${ignoredOptions.join(', ')} option(s) are no longer supported and will be ignored.\n`));
39
+ }
40
+ }
41
+ // Build validate command arguments
42
+ const validateArgs = ['validate'];
43
+ if (files.length > 0) {
44
+ validateArgs.push(...files);
45
+ }
46
+ if (options.quiet) {
47
+ validateArgs.push('--quiet');
48
+ }
49
+ if (options.json) {
50
+ validateArgs.push('--json');
51
+ }
52
+ // Spawn the validate command using the same CLI
53
+ const child = spawn(process.execPath, [process.argv[1], ...validateArgs], {
54
+ stdio: 'inherit',
55
+ cwd: process.cwd(),
56
+ });
57
+ child.on('close', (code) => {
58
+ process.exit(code ?? 0);
59
+ });
60
+ child.on('error', (error) => {
61
+ if (!options.json) {
62
+ console.error(chalk.red('Error:'), error.message);
63
+ }
64
+ else {
65
+ console.log(JSON.stringify({ error: error.message }));
66
+ }
67
+ process.exit(1);
68
+ });
69
+ });
70
+ return command;
71
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * List command - List all .canvas files in a project
3
+ */
4
+ import { Command } from 'commander';
5
+ export declare function createListCommand(): Command;
6
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiCpC,wBAAgB,iBAAiB,IAAI,OAAO,CAuD3C"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * List command - List all .canvas files in a project
3
+ */
4
+ import { Command } from 'commander';
5
+ import { readFileSync, statSync } from 'node:fs';
6
+ import { resolve, relative } from 'node:path';
7
+ import chalk from 'chalk';
8
+ import { globby } from 'globby';
9
+ function getCanvasInfo(filePath) {
10
+ try {
11
+ const absolutePath = resolve(filePath);
12
+ const content = readFileSync(absolutePath, 'utf8');
13
+ const canvas = JSON.parse(content);
14
+ const stats = statSync(absolutePath);
15
+ return {
16
+ file: relative(process.cwd(), absolutePath),
17
+ name: canvas.name || canvas.pv?.name || 'Untitled',
18
+ nodeCount: Array.isArray(canvas.nodes) ? canvas.nodes.length : 0,
19
+ edgeCount: Array.isArray(canvas.edges) ? canvas.edges.length : 0,
20
+ modified: stats.mtime,
21
+ };
22
+ }
23
+ catch {
24
+ return null;
25
+ }
26
+ }
27
+ export function createListCommand() {
28
+ const command = new Command('list');
29
+ command
30
+ .alias('ls')
31
+ .description('List all .canvas files in the project')
32
+ .option('-a, --all', 'Search all directories (not just .principal-views)')
33
+ .option('--json', 'Output as JSON')
34
+ .action(async (options) => {
35
+ try {
36
+ const patterns = options.all
37
+ ? ['**/*.canvas', '!node_modules/**']
38
+ : ['.principal-views/*.canvas'];
39
+ const files = await globby(patterns, {
40
+ expandDirectories: false,
41
+ });
42
+ if (files.length === 0) {
43
+ if (options.json) {
44
+ console.log(JSON.stringify({ files: [] }));
45
+ }
46
+ else {
47
+ console.log(chalk.yellow('No .canvas files found.'));
48
+ if (!options.all) {
49
+ console.log(chalk.dim('Run with --all to search all directories'));
50
+ }
51
+ console.log(chalk.dim('\nTo create a new canvas, run: npx @principal-ai/principal-studio-cli init'));
52
+ }
53
+ return;
54
+ }
55
+ const canvasInfos = files
56
+ .map(getCanvasInfo)
57
+ .filter((info) => info !== null)
58
+ .sort((a, b) => b.modified.getTime() - a.modified.getTime());
59
+ if (options.json) {
60
+ console.log(JSON.stringify({ files: canvasInfos }, null, 2));
61
+ }
62
+ else {
63
+ console.log(chalk.bold(`\nFound ${canvasInfos.length} canvas file(s):\n`));
64
+ for (const info of canvasInfos) {
65
+ console.log(` ${chalk.cyan(info.file)}`);
66
+ console.log(` ${chalk.bold(info.name)}`);
67
+ console.log(chalk.dim(` ${info.nodeCount} nodes, ${info.edgeCount} edges`));
68
+ console.log('');
69
+ }
70
+ }
71
+ }
72
+ catch (error) {
73
+ console.error(chalk.red('Error:'), error.message);
74
+ process.exit(1);
75
+ }
76
+ });
77
+ return command;
78
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Migrate Canvas Node Types
3
+ *
4
+ * Transforms canvas files from the legacy format (type: "text" + pv.nodeType)
5
+ * to the new semantic format (type: "otel-event", "otel-scope", etc.)
6
+ */
7
+ import { Command } from 'commander';
8
+ export declare function createMigrateNodesCommand(): Command;
9
+ //# sourceMappingURL=migrate-nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-nodes.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-nodes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwSpC,wBAAgB,yBAAyB,IAAI,OAAO,CA4FnD"}