@factorialco/fcode-cli 1.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 (234) hide show
  1. package/README.md +1021 -0
  2. package/bin/dev +17 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/run +7 -0
  5. package/bin/run.cmd +3 -0
  6. package/dist/commands/add.d.ts +6 -0
  7. package/dist/commands/add.js +22 -0
  8. package/dist/commands/clone.d.ts +26 -0
  9. package/dist/commands/clone.js +177 -0
  10. package/dist/commands/dependencies/add.d.ts +9 -0
  11. package/dist/commands/dependencies/add.js +13 -0
  12. package/dist/commands/dependencies/install.d.ts +14 -0
  13. package/dist/commands/dependencies/install.js +44 -0
  14. package/dist/commands/dependencies/pull.d.ts +12 -0
  15. package/dist/commands/dependencies/pull.js +14 -0
  16. package/dist/commands/dependencies/push.d.ts +12 -0
  17. package/dist/commands/dependencies/push.js +14 -0
  18. package/dist/commands/dependencies/reset.d.ts +9 -0
  19. package/dist/commands/dependencies/reset.js +13 -0
  20. package/dist/commands/dependencies/status.d.ts +9 -0
  21. package/dist/commands/dependencies/status.js +13 -0
  22. package/dist/commands/http.d.ts +22 -0
  23. package/dist/commands/http.js +272 -0
  24. package/dist/commands/login.d.ts +18 -0
  25. package/dist/commands/login.js +62 -0
  26. package/dist/commands/logout.d.ts +10 -0
  27. package/dist/commands/logout.js +34 -0
  28. package/dist/commands/modules/add.d.ts +9 -0
  29. package/dist/commands/modules/add.js +13 -0
  30. package/dist/commands/modules/pull.d.ts +13 -0
  31. package/dist/commands/modules/pull.js +43 -0
  32. package/dist/commands/modules/push.d.ts +13 -0
  33. package/dist/commands/modules/push.js +35 -0
  34. package/dist/commands/modules/remove.d.ts +9 -0
  35. package/dist/commands/modules/remove.js +19 -0
  36. package/dist/commands/modules/reset.d.ts +9 -0
  37. package/dist/commands/modules/reset.js +13 -0
  38. package/dist/commands/modules/status.d.ts +11 -0
  39. package/dist/commands/modules/status.js +40 -0
  40. package/dist/commands/pre-debug.d.ts +20 -0
  41. package/dist/commands/pre-debug.js +120 -0
  42. package/dist/commands/process-metadata.d.ts +18 -0
  43. package/dist/commands/process-metadata.js +63 -0
  44. package/dist/commands/processes/add.d.ts +9 -0
  45. package/dist/commands/processes/add.js +13 -0
  46. package/dist/commands/processes/install-dependencies.d.ts +14 -0
  47. package/dist/commands/processes/install-dependencies.js +30 -0
  48. package/dist/commands/processes/pull.d.ts +13 -0
  49. package/dist/commands/processes/pull.js +47 -0
  50. package/dist/commands/processes/push.d.ts +13 -0
  51. package/dist/commands/processes/push.js +39 -0
  52. package/dist/commands/processes/remove.d.ts +9 -0
  53. package/dist/commands/processes/remove.js +19 -0
  54. package/dist/commands/processes/reset.d.ts +9 -0
  55. package/dist/commands/processes/reset.js +13 -0
  56. package/dist/commands/processes/status.d.ts +11 -0
  57. package/dist/commands/processes/status.js +58 -0
  58. package/dist/commands/pull.d.ts +9 -0
  59. package/dist/commands/pull.js +32 -0
  60. package/dist/commands/push.d.ts +9 -0
  61. package/dist/commands/push.js +29 -0
  62. package/dist/commands/remote/add.d.ts +10 -0
  63. package/dist/commands/remote/add.js +32 -0
  64. package/dist/commands/remote/list.d.ts +7 -0
  65. package/dist/commands/remote/list.js +33 -0
  66. package/dist/commands/remote/set.d.ts +10 -0
  67. package/dist/commands/remote/set.js +28 -0
  68. package/dist/commands/reset.d.ts +6 -0
  69. package/dist/commands/reset.js +19 -0
  70. package/dist/commands/run.d.ts +16 -0
  71. package/dist/commands/run.js +56 -0
  72. package/dist/commands/runtime-env.d.ts +12 -0
  73. package/dist/commands/runtime-env.js +42 -0
  74. package/dist/commands/settings/get.d.ts +12 -0
  75. package/dist/commands/settings/get.js +67 -0
  76. package/dist/commands/settings/remove.d.ts +9 -0
  77. package/dist/commands/settings/remove.js +35 -0
  78. package/dist/commands/settings/set.d.ts +10 -0
  79. package/dist/commands/settings/set.js +39 -0
  80. package/dist/commands/setup-debug.d.ts +12 -0
  81. package/dist/commands/setup-debug.js +118 -0
  82. package/dist/commands/status.d.ts +6 -0
  83. package/dist/commands/status.js +22 -0
  84. package/dist/commands/team/pull.d.ts +8 -0
  85. package/dist/commands/team/pull.js +23 -0
  86. package/dist/commands/team/push.d.ts +11 -0
  87. package/dist/commands/team/push.js +41 -0
  88. package/dist/commands/team/status.d.ts +8 -0
  89. package/dist/commands/team/status.js +40 -0
  90. package/dist/commands/test/scaffold.d.ts +9 -0
  91. package/dist/commands/test/scaffold.js +61 -0
  92. package/dist/commands/test.d.ts +13 -0
  93. package/dist/commands/test.js +72 -0
  94. package/dist/commands/variables/add.d.ts +12 -0
  95. package/dist/commands/variables/add.js +21 -0
  96. package/dist/commands/variables/pull.d.ts +12 -0
  97. package/dist/commands/variables/pull.js +14 -0
  98. package/dist/commands/variables/push.d.ts +12 -0
  99. package/dist/commands/variables/push.js +14 -0
  100. package/dist/commands/variables/remove.d.ts +9 -0
  101. package/dist/commands/variables/remove.js +19 -0
  102. package/dist/commands/variables/reset.d.ts +9 -0
  103. package/dist/commands/variables/reset.js +13 -0
  104. package/dist/commands/variables/status.d.ts +12 -0
  105. package/dist/commands/variables/status.js +58 -0
  106. package/dist/config/global.d.ts +15 -0
  107. package/dist/config/global.js +77 -0
  108. package/dist/config/index.d.ts +14 -0
  109. package/dist/config/index.js +44 -0
  110. package/dist/config/remote.d.ts +15 -0
  111. package/dist/config/remote.js +60 -0
  112. package/dist/config/settings.d.ts +16 -0
  113. package/dist/config/settings.js +54 -0
  114. package/dist/config/workspace.d.ts +28 -0
  115. package/dist/config/workspace.js +158 -0
  116. package/dist/core/commands/api-client-command.d.ts +6 -0
  117. package/dist/core/commands/api-client-command.js +30 -0
  118. package/dist/core/commands/base-command.d.ts +11 -0
  119. package/dist/core/commands/base-command.js +61 -0
  120. package/dist/core/commands/dependency-command.d.ts +5 -0
  121. package/dist/core/commands/dependency-command.js +16 -0
  122. package/dist/core/commands/modules-command.d.ts +7 -0
  123. package/dist/core/commands/modules-command.js +18 -0
  124. package/dist/core/commands/processes-command.d.ts +8 -0
  125. package/dist/core/commands/processes-command.js +27 -0
  126. package/dist/core/commands/resource-command.d.ts +24 -0
  127. package/dist/core/commands/resource-command.js +92 -0
  128. package/dist/core/commands/variables-command.d.ts +5 -0
  129. package/dist/core/commands/variables-command.js +16 -0
  130. package/dist/core/dependencies/env-dependencies-command.d.ts +19 -0
  131. package/dist/core/dependencies/env-dependencies-command.js +70 -0
  132. package/dist/core/dependencies/env-process-dependencies-command.d.ts +15 -0
  133. package/dist/core/dependencies/env-process-dependencies-command.js +78 -0
  134. package/dist/core/dependencies/javascript-env-dependencies.d.ts +8 -0
  135. package/dist/core/dependencies/javascript-env-dependencies.js +77 -0
  136. package/dist/core/dependencies/python-env-dependencies.d.ts +9 -0
  137. package/dist/core/dependencies/python-env-dependencies.js +91 -0
  138. package/dist/core/errors.d.ts +55 -0
  139. package/dist/core/errors.js +144 -0
  140. package/dist/core/executors/execution-task.d.ts +29 -0
  141. package/dist/core/executors/execution-task.js +139 -0
  142. package/dist/core/executors/javascript-execution-task.d.ts +13 -0
  143. package/dist/core/executors/javascript-execution-task.js +618 -0
  144. package/dist/core/executors/python/context.d.ts +2 -0
  145. package/dist/core/executors/python/context.js +3 -0
  146. package/dist/core/executors/python/datastore.d.ts +2 -0
  147. package/dist/core/executors/python/datastore.js +4 -0
  148. package/dist/core/executors/python-execution-task.d.ts +11 -0
  149. package/dist/core/executors/python-execution-task.js +173 -0
  150. package/dist/core/executors/source-code-sanitizer.d.ts +4 -0
  151. package/dist/core/executors/source-code-sanitizer.js +45 -0
  152. package/dist/core/resource-merger.d.ts +14 -0
  153. package/dist/core/resource-merger.js +155 -0
  154. package/dist/core/resource-pusher.d.ts +12 -0
  155. package/dist/core/resource-pusher.js +133 -0
  156. package/dist/core/resource-repository.d.ts +8 -0
  157. package/dist/core/resource-repository.js +2 -0
  158. package/dist/core/types.d.ts +290 -0
  159. package/dist/core/types.js +238 -0
  160. package/dist/core/utils/dependencies.d.ts +5 -0
  161. package/dist/core/utils/dependencies.js +82 -0
  162. package/dist/core/utils/variables.d.ts +4 -0
  163. package/dist/core/utils/variables.js +10 -0
  164. package/dist/hooks/init/auth.d.ts +3 -0
  165. package/dist/hooks/init/auth.js +28 -0
  166. package/dist/hooks/init/update.d.ts +3 -0
  167. package/dist/hooks/init/update.js +42 -0
  168. package/dist/index.d.ts +1 -0
  169. package/dist/index.js +4 -0
  170. package/dist/repositories/process.d.ts +36 -0
  171. package/dist/repositories/process.js +339 -0
  172. package/dist/repositories/programming-language-manifest.d.ts +17 -0
  173. package/dist/repositories/programming-language-manifest.js +95 -0
  174. package/dist/repositories/resource.d.ts +29 -0
  175. package/dist/repositories/resource.js +79 -0
  176. package/dist/repositories/script-library.d.ts +28 -0
  177. package/dist/repositories/script-library.js +164 -0
  178. package/dist/repositories/team.d.ts +23 -0
  179. package/dist/repositories/team.js +74 -0
  180. package/dist/repositories/variable.d.ts +26 -0
  181. package/dist/repositories/variable.js +174 -0
  182. package/dist/runtime/executor.js +87 -0
  183. package/dist/runtime/executor.py +81 -0
  184. package/dist/runtime/libs/node/fcode/index.js +1 -0
  185. package/dist/runtime/libs/python/fcode/__init__.py +75 -0
  186. package/dist/runtime/libs/python/fcode/context.py +98 -0
  187. package/dist/runtime/libs/python/fcode/datastore.py +35 -0
  188. package/dist/runtime/libs/python/fcode/schedule.py +45 -0
  189. package/dist/runtime/libs/python/fcode/storage.py +271 -0
  190. package/dist/runtime/libs/python/fcode/variables.py +102 -0
  191. package/dist/services/auth-service.d.ts +12 -0
  192. package/dist/services/auth-service.js +114 -0
  193. package/dist/services/credential-prompter.d.ts +6 -0
  194. package/dist/services/credential-prompter.js +60 -0
  195. package/dist/services/fcode-graphql-client.d.ts +45 -0
  196. package/dist/services/fcode-graphql-client.js +721 -0
  197. package/dist/services/http-server.d.ts +3 -0
  198. package/dist/services/http-server.js +17 -0
  199. package/dist/services/oauth-browser-service.d.ts +9 -0
  200. package/dist/services/oauth-browser-service.js +164 -0
  201. package/dist/services/process-parameters-sampler.d.ts +2 -0
  202. package/dist/services/process-parameters-sampler.js +41 -0
  203. package/dist/services/process-runner.d.ts +22 -0
  204. package/dist/services/process-runner.js +97 -0
  205. package/dist/services/resource-checker.d.ts +8 -0
  206. package/dist/services/resource-checker.js +82 -0
  207. package/dist/services/test-runner.d.ts +17 -0
  208. package/dist/services/test-runner.js +228 -0
  209. package/dist/utils/canonical-hash.d.ts +9 -0
  210. package/dist/utils/canonical-hash.js +30 -0
  211. package/dist/utils/cli/index.d.ts +14 -0
  212. package/dist/utils/cli/index.js +50 -0
  213. package/dist/utils/cli/screen.d.ts +2 -0
  214. package/dist/utils/cli/screen.js +25 -0
  215. package/dist/utils/cli/styled/table.d.ts +23 -0
  216. package/dist/utils/cli/styled/table.js +272 -0
  217. package/dist/utils/colorize-resource.d.ts +1 -0
  218. package/dist/utils/colorize-resource.js +7 -0
  219. package/dist/utils/env-utils.d.ts +2 -0
  220. package/dist/utils/env-utils.js +16 -0
  221. package/dist/utils/file-utils.d.ts +11 -0
  222. package/dist/utils/file-utils.js +33 -0
  223. package/dist/utils/filenamify.d.ts +4 -0
  224. package/dist/utils/filenamify.js +73 -0
  225. package/dist/utils/gitignore.d.ts +17 -0
  226. package/dist/utils/gitignore.js +60 -0
  227. package/dist/utils/promise.d.ts +4 -0
  228. package/dist/utils/promise.js +38 -0
  229. package/dist/utils/url-utils.d.ts +2 -0
  230. package/dist/utils/url-utils.js +10 -0
  231. package/dist/utils/variable-warnings.d.ts +8 -0
  232. package/dist/utils/variable-warnings.js +38 -0
  233. package/oclif.manifest.json +1783 -0
  234. package/package.json +129 -0
package/bin/dev ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ const path = require('path')
6
+ const project = path.join(__dirname, '..', 'tsconfig.json')
7
+
8
+ // In dev mode -> use ts-node and dev plugins
9
+ process.env.NODE_ENV = 'development'
10
+
11
+ require('ts-node').register({project})
12
+
13
+ // In dev mode, always show stack traces
14
+ oclif.settings.debug = true;
15
+
16
+ // Start the CLI
17
+ oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\dev" %*
package/bin/run ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { run, handle, flush } = require('@oclif/core')
4
+
5
+ run()
6
+ .catch(async (error) => handle(error))
7
+ .finally(async () => flush())
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
@@ -0,0 +1,6 @@
1
+ import BaseCommand from '../core/commands/base-command';
2
+ export default class AddCommand extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const base_command_1 = require("../core/commands/base-command");
4
+ const add_1 = require("./processes/add");
5
+ const add_2 = require("./modules/add");
6
+ const add_3 = require("./variables/add");
7
+ const add_4 = require("./dependencies/add");
8
+ const cli_1 = require("../utils/cli");
9
+ class AddCommand extends base_command_1.default {
10
+ async run() {
11
+ await this.parse(AddCommand);
12
+ await this.logActiveTeam();
13
+ cli_1.default.log('');
14
+ await add_1.default.run([]);
15
+ await add_2.default.run([]);
16
+ await add_3.default.run([]);
17
+ await add_4.default.run([]);
18
+ }
19
+ }
20
+ AddCommand.description = 'Keeps track of new local components';
21
+ AddCommand.examples = ['$ fcode add'];
22
+ exports.default = AddCommand;
@@ -0,0 +1,26 @@
1
+ import { Command } from '@oclif/core';
2
+ import { TeamOrigin } from '../core/types';
3
+ export default class Clone extends Command {
4
+ static args: {
5
+ team: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ skipSkillsSetup: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ checkWorkspaceAlreadyCloned(slug: string): Promise<void>;
13
+ checkWorkspaceIsEmpty(slug: string): Promise<void>;
14
+ cloneTeam(origin: TeamOrigin, skipSkillsSetup?: boolean): Promise<void>;
15
+ createWorkspaceConfig(origin: TeamOrigin): Promise<void>;
16
+ createWorkspaceDatastore(slug: string): void;
17
+ createWorkspaceStorage(slug: string): void;
18
+ createWorkspaceGitIgnore(slug: string): Promise<void>;
19
+ createWorkspaceLocalVariables(slug: string): Promise<void>;
20
+ private skillsInstallHint;
21
+ setupSkills(): Promise<void>;
22
+ catch(error: any): Promise<void>;
23
+ init(): Promise<void>;
24
+ mkdirWorkspace(slug: string): Promise<void>;
25
+ run(): Promise<void>;
26
+ }
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const node_child_process_1 = require("node:child_process");
5
+ const fs = require("fs-extra");
6
+ const path = require("node:path");
7
+ const global_1 = require("../config/global");
8
+ const workspace_1 = require("../config/workspace");
9
+ const pull_1 = require("./pull");
10
+ const types_1 = require("../core/types");
11
+ const cli_1 = require("../utils/cli");
12
+ const settings_1 = require("../config/settings");
13
+ const SKILLS_REPO = 'factorialco/factorial-code-skills';
14
+ class Clone extends core_1.Command {
15
+ async checkWorkspaceAlreadyCloned(slug) {
16
+ try {
17
+ await new workspace_1.default(path.join(process.cwd(), slug)).getActiveTeam();
18
+ }
19
+ catch {
20
+ return;
21
+ }
22
+ this.error(`Workspace '${slug}' already cloned.`, {
23
+ code: 'ERR_WORKSPACE_ALREADY_CLONED',
24
+ exit: 1,
25
+ suggestions: [`cd ${slug}`, 'fcode pull'],
26
+ });
27
+ }
28
+ async checkWorkspaceIsEmpty(slug) {
29
+ const files = fs.readdirSync(slug);
30
+ if (files.length == 0) {
31
+ return;
32
+ }
33
+ const envValue = process.env.IGNORE_WORKSPACE_NOT_EMPTY;
34
+ const ignoreWorkspaceNotEmpty = envValue === 'true' || envValue === 'false'
35
+ ? envValue === 'true'
36
+ : (await new global_1.default().getSetting(settings_1.SettingKeys.IGNORE_WORKSPACE_NOT_EMPTY)) === 'true';
37
+ if (!ignoreWorkspaceNotEmpty) {
38
+ this.error(`Destination path '${slug}' already exists and is not empty.`, {
39
+ code: 'ERR_WORKSPACE_DIR_IS_NOT_EMPTY',
40
+ exit: 1,
41
+ });
42
+ }
43
+ }
44
+ async cloneTeam(origin, skipSkillsSetup = false) {
45
+ await this.mkdirWorkspace(origin.slug);
46
+ await this.createWorkspaceConfig(origin);
47
+ await this.createWorkspaceGitIgnore(origin.slug);
48
+ this.createWorkspaceDatastore(origin.slug);
49
+ this.createWorkspaceStorage(origin.slug);
50
+ await this.createWorkspaceLocalVariables(origin.slug);
51
+ process.chdir(origin.slug);
52
+ await pull_1.default.run([]);
53
+ if (!skipSkillsSetup) {
54
+ await this.setupSkills();
55
+ }
56
+ }
57
+ async createWorkspaceConfig(origin) {
58
+ const config = new workspace_1.default(path.join(process.cwd(), origin.slug));
59
+ await config.init(origin);
60
+ }
61
+ createWorkspaceDatastore(slug) {
62
+ fs.outputFileSync(path.join(slug, 'datastore.json'), '{}');
63
+ }
64
+ createWorkspaceStorage(slug) {
65
+ fs.mkdirSync(path.join(slug, 'storage'));
66
+ }
67
+ async createWorkspaceGitIgnore(slug) {
68
+ const globalConfig = new global_1.default();
69
+ const localVariablesFileName = await globalConfig.getSetting(settings_1.SettingKeys.LOCAL_VARIABLES_FILE_NAME);
70
+ const gitIgnorePatterns = [localVariablesFileName, 'datastore.json', '.env', 'storage/*'];
71
+ fs.outputFileSync(path.join(slug, '.gitignore'), gitIgnorePatterns.join('\n'));
72
+ }
73
+ async createWorkspaceLocalVariables(slug) {
74
+ const globalConfig = new global_1.default();
75
+ const localVariablesFileName = await globalConfig.getSetting(settings_1.SettingKeys.LOCAL_VARIABLES_FILE_NAME);
76
+ fs.outputFileSync(path.join(slug, localVariablesFileName), '');
77
+ }
78
+ skillsInstallHint() {
79
+ cli_1.default.log('💡 Install the Factorial Code agent skills later with:');
80
+ cli_1.default.log(` npx skills add ${SKILLS_REPO} -s '*'`);
81
+ }
82
+ async setupSkills() {
83
+ cli_1.default.log('');
84
+ // `npx --yes skills add <repo> -s '*'` — preselect all skills; the skills CLI
85
+ // then handles scope (project/global) and assistant selection interactively.
86
+ await new Promise((resolve) => {
87
+ const child = (0, node_child_process_1.spawn)('npx', ['--yes', 'skills', 'add', SKILLS_REPO, '-s', '*'], { stdio: 'inherit' });
88
+ child.on('error', () => {
89
+ // npx not available (or failed to launch) — don't fail the clone, just tell the user how to do it.
90
+ cli_1.default.log("\n⚠️ Couldn't run npx automatically (is Node.js / npx installed?).");
91
+ this.skillsInstallHint();
92
+ resolve();
93
+ });
94
+ child.on('close', (code) => {
95
+ if (code !== 0) {
96
+ cli_1.default.log("\n⚠️ Skill installation didn't complete.");
97
+ this.skillsInstallHint();
98
+ }
99
+ resolve();
100
+ });
101
+ });
102
+ }
103
+ async catch(error) {
104
+ const suggestions = error?.suggestions ?? [];
105
+ const hint = suggestions.length > 0 ? ` Try this: ${suggestions.map((suggestion) => `'${suggestion}'`).join('\n')} \n` : '';
106
+ cli_1.default.error(error.message + hint);
107
+ }
108
+ async init() {
109
+ const { args } = await this.parse(Clone);
110
+ let { url } = (0, global_1.parseTeamOrigin)(args.team || '');
111
+ const { authUrl } = await new global_1.default().getAuthInfo(url);
112
+ await this.config.runHook('auth', { argv: [url, authUrl], id: 'login' });
113
+ }
114
+ async mkdirWorkspace(slug) {
115
+ return new Promise((resolve, reject) => {
116
+ fs.mkdir(slug, {}, (error) => {
117
+ if (error) {
118
+ if (error.code === 'EEXIST') {
119
+ this.checkWorkspaceAlreadyCloned(slug)
120
+ .then(() => this.checkWorkspaceIsEmpty(slug))
121
+ .then(() => resolve())
122
+ .catch((err) => reject(err));
123
+ }
124
+ else {
125
+ reject(error);
126
+ }
127
+ }
128
+ else {
129
+ const globalConfig = new global_1.default();
130
+ globalConfig
131
+ .getSetting(settings_1.SettingKeys.VARIABLES_FILE_NAME)
132
+ .then((variablesFileName) => {
133
+ fs.mkdirSync(path.join(slug, 'processes'));
134
+ fs.mkdirSync(path.join(slug, 'modules'));
135
+ fs.mkdirSync(path.join(slug, 'dependencies'));
136
+ fs.createFileSync(path.join(slug, variablesFileName));
137
+ resolve();
138
+ })
139
+ .catch((err) => reject(err));
140
+ }
141
+ });
142
+ });
143
+ }
144
+ async run() {
145
+ const { args, flags } = await this.parse(Clone);
146
+ let { slug, url } = (0, global_1.parseTeamOrigin)(args.team || '');
147
+ // Team access is enforced by the platform when pulling; we no longer gate on the
148
+ // locally cached group list, which goes stale for teams created after login.
149
+ if (!slug) {
150
+ const userInfo = await new global_1.default().getUserInfo(url);
151
+ const teams = userInfo.groups ?? [];
152
+ if (teams.length === 0) {
153
+ cli_1.default.log(`ℹ️ Pass a team to clone: fcode clone [team]`);
154
+ }
155
+ else {
156
+ cli_1.default.log(`🏢 Your teams: \n\t${teams.join('\n\t')}`);
157
+ }
158
+ return;
159
+ }
160
+ let skipSkillsSetup = flags.skipSkillsSetup;
161
+ if (skipSkillsSetup === undefined) {
162
+ skipSkillsSetup = (await new global_1.default().getSetting(settings_1.SettingKeys.SKIP_SKILLS_SETUP)) === 'true';
163
+ }
164
+ await this.cloneTeam({ url, slug }, skipSkillsSetup);
165
+ cli_1.default.log(`\n🎉 ${args.team} team workspace cloned successfully!\n`);
166
+ cli_1.default.log(`$ cd ${slug}\n`);
167
+ }
168
+ }
169
+ Clone.args = types_1.TeamNameArg;
170
+ Clone.description = 'Clone team workspace from cloud';
171
+ Clone.examples = ['$ fcode clone', '$ fcode clone [team]'];
172
+ Clone.flags = {
173
+ skipSkillsSetup: core_1.Flags.boolean({
174
+ description: 'Skip installation of the Factorial Code agent skills',
175
+ }),
176
+ };
177
+ exports.default = Clone;
@@ -0,0 +1,9 @@
1
+ import DependencyCommand from '../../core/commands/dependency-command';
2
+ export default class DependenciesAdd extends DependencyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dependency_command_1 = require("../../core/commands/dependency-command");
4
+ const types_1 = require("../../core/types");
5
+ class DependenciesAdd extends dependency_command_1.default {
6
+ async run() {
7
+ await super.addResources();
8
+ }
9
+ }
10
+ DependenciesAdd.description = 'Keeps track of dependencies';
11
+ DependenciesAdd.examples = ['$ fcode dependencies:add'];
12
+ DependenciesAdd.args = types_1.ResourceSlugArg;
13
+ exports.default = DependenciesAdd;
@@ -0,0 +1,14 @@
1
+ import BaseCommand from '../../core/commands/base-command';
2
+ export default class Dependencies extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ programmingLanguage: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ check: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ reset: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_command_1 = require("../../core/commands/base-command");
5
+ const python_env_dependencies_1 = require("../../core/dependencies/python-env-dependencies");
6
+ const javascript_env_dependencies_1 = require("../../core/dependencies/javascript-env-dependencies");
7
+ const types_1 = require("../../core/types");
8
+ class Dependencies extends base_command_1.default {
9
+ async run() {
10
+ await super.init();
11
+ const { args: { programmingLanguage }, flags: { check, reset, force }, } = await this.parse(Dependencies);
12
+ const languages = programmingLanguage === 'all' ? ['javascript', 'python'] : [programmingLanguage];
13
+ const args = [];
14
+ if (check) {
15
+ args.push('--check');
16
+ }
17
+ if (reset) {
18
+ args.push('--reset');
19
+ }
20
+ if (force) {
21
+ args.push('--force');
22
+ }
23
+ for (const language of languages) {
24
+ if ('PYTHON' === language.toUpperCase()) {
25
+ await python_env_dependencies_1.default.run(args);
26
+ }
27
+ else {
28
+ await javascript_env_dependencies_1.default.run(args);
29
+ }
30
+ }
31
+ }
32
+ }
33
+ Dependencies.description = 'Install Factorial Code dependencies';
34
+ Dependencies.examples = ['$ fcode dependencies:install [programmingLanguage]'];
35
+ Dependencies.args = {
36
+ programmingLanguage: core_1.Args.string({
37
+ description: 'Programming language',
38
+ name: 'programmingLanguage',
39
+ default: 'all',
40
+ options: ['all', 'javascript', 'python'],
41
+ }),
42
+ };
43
+ Dependencies.flags = types_1.DependenciesFlags;
44
+ exports.default = Dependencies;
@@ -0,0 +1,12 @@
1
+ import DependencyCommand from '../../core/commands/dependency-command';
2
+ export default class DependenciesPull extends DependencyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const types_1 = require("../../core/types");
4
+ const dependency_command_1 = require("../../core/commands/dependency-command");
5
+ class DependenciesPull extends dependency_command_1.default {
6
+ async run() {
7
+ await super.pullResources();
8
+ }
9
+ }
10
+ DependenciesPull.description = 'Fetch all dependencies from cloud and save them locally';
11
+ DependenciesPull.examples = ['$ fcode dependencies:pull'];
12
+ DependenciesPull.args = types_1.ResourceSlugArg;
13
+ DependenciesPull.flags = types_1.ForceFlag;
14
+ exports.default = DependenciesPull;
@@ -0,0 +1,12 @@
1
+ import DependencyCommand from '../../core/commands/dependency-command';
2
+ export default class DependenciesPush extends DependencyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const types_1 = require("../../core/types");
4
+ const dependency_command_1 = require("../../core/commands/dependency-command");
5
+ class DependenciesPush extends dependency_command_1.default {
6
+ async run() {
7
+ await super.pushResources();
8
+ }
9
+ }
10
+ DependenciesPush.description = 'Update cloud dependencies with local ones';
11
+ DependenciesPush.examples = ['$ fcode dependencies:push'];
12
+ DependenciesPush.args = types_1.ResourceSlugArg;
13
+ DependenciesPush.flags = types_1.ForceFlag;
14
+ exports.default = DependenciesPush;
@@ -0,0 +1,9 @@
1
+ import DependencyCommand from '../../core/commands/dependency-command';
2
+ export default class DependenciesReset extends DependencyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dependency_command_1 = require("../../core/commands/dependency-command");
4
+ const types_1 = require("../../core/types");
5
+ class DependenciesReset extends dependency_command_1.default {
6
+ async run() {
7
+ await super.resetResources();
8
+ }
9
+ }
10
+ DependenciesReset.description = 'Reset dependencies with contents from current remote';
11
+ DependenciesReset.examples = ['$ fcode dependencies:reset'];
12
+ DependenciesReset.args = types_1.ResourceSlugArg;
13
+ exports.default = DependenciesReset;
@@ -0,0 +1,9 @@
1
+ import DependencyCommand from '../../core/commands/dependency-command';
2
+ export default class DependenciesStatus extends DependencyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dependency_command_1 = require("../../core/commands/dependency-command");
4
+ const types_1 = require("../../core/types");
5
+ class DependenciesStatus extends dependency_command_1.default {
6
+ async run() {
7
+ await this.resourcesLog();
8
+ }
9
+ }
10
+ DependenciesStatus.description = 'List all dependencies status';
11
+ DependenciesStatus.examples = ['$ fcode dependencies:status'];
12
+ DependenciesStatus.args = types_1.ResourceSlugArg;
13
+ exports.default = DependenciesStatus;
@@ -0,0 +1,22 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Http extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ port: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ 'auth-user': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ 'auth-password': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ jsonLogs: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<void>;
13
+ /**
14
+ * Enforces the process's configured webhook basic auth, simulating the cloud
15
+ * webhook endpoint. The username/password come from processes/<slug>/metadata.json;
16
+ * an env-var placeholder (e.g. $WEBHOOK_PASSWORD) is resolved against the workspace
17
+ * variables. Returns true when the request may proceed, false after writing a 401.
18
+ */
19
+ private _checkWebhookAuth;
20
+ private _handleProcessExecution;
21
+ private _sendResponse;
22
+ }