@quantbrasil/cli 0.1.0-beta.6 → 0.1.0-beta.8

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 (40) hide show
  1. package/README.md +41 -0
  2. package/dist/cli/index.d.ts +6 -0
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +20 -1
  5. package/dist/cli/prompt.d.ts +1 -0
  6. package/dist/cli/prompt.d.ts.map +1 -1
  7. package/dist/cli/prompt.js +17 -0
  8. package/dist/cli/skills.d.ts +9 -0
  9. package/dist/cli/skills.d.ts.map +1 -1
  10. package/dist/cli/skills.js +68 -4
  11. package/dist/commands/screening.d.ts +120 -0
  12. package/dist/commands/screening.d.ts.map +1 -0
  13. package/dist/commands/screening.js +361 -0
  14. package/dist/commands/skills.js +7 -7
  15. package/dist/commands/update.d.ts +23 -0
  16. package/dist/commands/update.d.ts.map +1 -0
  17. package/dist/commands/update.js +209 -0
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +2 -0
  21. package/dist/vendor/core/capabilities/index.d.ts +1 -0
  22. package/dist/vendor/core/capabilities/index.d.ts.map +1 -1
  23. package/dist/vendor/core/capabilities/index.js +1 -0
  24. package/dist/vendor/core/capabilities/registry.d.ts +266 -0
  25. package/dist/vendor/core/capabilities/registry.d.ts.map +1 -1
  26. package/dist/vendor/core/capabilities/registry.js +2 -0
  27. package/dist/vendor/core/capabilities/screening.d.ts +136 -0
  28. package/dist/vendor/core/capabilities/screening.d.ts.map +1 -0
  29. package/dist/vendor/core/capabilities/screening.js +155 -0
  30. package/dist/vendor/core/capabilities/types.d.ts +1 -1
  31. package/dist/vendor/core/capabilities/types.d.ts.map +1 -1
  32. package/package.json +3 -3
  33. package/skills/quantbrasil/SKILL.md +16 -11
  34. package/skills/quantbrasil/references/cli.md +53 -0
  35. package/skills/quantbrasil/references/costs.md +6 -1
  36. package/skills/quantbrasil/references/portfolios.md +13 -2
  37. package/skills/quantbrasil/references/quality-eval-queries.json +127 -0
  38. package/skills/quantbrasil/references/screening.md +212 -0
  39. package/skills/quantbrasil/references/unsupported.md +2 -0
  40. package/skills/quantbrasil/references/workflows.md +24 -0
package/README.md CHANGED
@@ -31,6 +31,7 @@ that file only exists inside this package.
31
31
  node ./bin/quantbrasil.js auth login --api-key qb_live_<id>.<secret>
32
32
  node ./bin/quantbrasil.js whoami
33
33
  node ./bin/quantbrasil.js skills install --all
34
+ node ./bin/quantbrasil.js update
34
35
  node ./bin/quantbrasil.js --status
35
36
  node ./bin/quantbrasil.js auth logout
36
37
  ```
@@ -72,6 +73,40 @@ quantbrasil holdings historical-return 182 --from 2025-01-01 --to 2026-01-01
72
73
  quantbrasil holdings historical-return 182 --period 1y
73
74
  quantbrasil holdings beta 182 --years 3
74
75
  quantbrasil holdings var 182 --years 1 --confidence 95
76
+ quantbrasil screening universes
77
+ quantbrasil screening indicators
78
+ quantbrasil screening run --system acoes-mais-liquidas --query-file ./screening.json
79
+ quantbrasil screening run --watchlist 93 --query-file ./screening.json --limit 25
80
+ cat ./screening.json | quantbrasil screening run --holding 182 --query-file -
81
+ ```
82
+
83
+ Example `screening.json`:
84
+
85
+ ```json
86
+ {
87
+ "query": {
88
+ "comparison": {
89
+ "left": {
90
+ "indicator": {
91
+ "name": "RSI",
92
+ "timeframe": "D1",
93
+ "offset": 0,
94
+ "params": {
95
+ "period": 14
96
+ }
97
+ }
98
+ },
99
+ "operator": "lt",
100
+ "right": {
101
+ "constant": {
102
+ "value": 30
103
+ }
104
+ }
105
+ }
106
+ },
107
+ "limit": 50,
108
+ "sort": "ticker"
109
+ }
75
110
  ```
76
111
 
77
112
  ## Local config
@@ -111,8 +146,14 @@ quantbrasil init
111
146
  quantbrasil --status
112
147
  quantbrasil auth login --api-key qb_live_<id>.<secret>
113
148
  quantbrasil skills install --all
149
+ quantbrasil update
114
150
  ```
115
151
 
152
+ `quantbrasil update` checks the current global package against
153
+ `@quantbrasil/cli@beta`, checks whether the bundled skill is missing or stale,
154
+ shows the planned actions, and asks for confirmation before updating. Use
155
+ `quantbrasil update --yes` only in noninteractive automation.
156
+
116
157
  ## Publishing
117
158
 
118
159
  Publish from `monorepo/packages/cli`. The package build vendors the private
@@ -3,8 +3,10 @@ import { type CapabilitiesCommandIO, runCapabilitiesCommand } from "../commands/
3
3
  import { runMarketAssetsCommand, runMarketPriceCommand } from "../commands/market.js";
4
4
  import { runInitCommand } from "../commands/init.js";
5
5
  import { runHoldingCreateCommand, runHoldingBetaCommand, runHoldingGetCommand, runHoldingHistoricalReturnCommand, runHoldingListCommand, runHoldingRenameCommand, runHoldingSetPositionsCommand, runHoldingSetTargetsCommand, runHoldingVarCommand, runWatchlistAddAssetsCommand, runWatchlistCreateCommand, runWatchlistGetCommand, runWatchlistListCommand, runWatchlistRemoveAssetsCommand, runWatchlistRenameCommand } from "../commands/portfolios.js";
6
+ import { runScreeningIndicatorsCommand, runScreeningRunCommand, runScreeningUniversesCommand } from "../commands/screening.js";
6
7
  import { runSkillsInstallCommand } from "../commands/skills.js";
7
8
  import { runStatusCommand } from "../commands/status.js";
9
+ import { runUpdateCommand, type UpdateCommandRunner } from "../commands/update.js";
8
10
  import { type TerminalWriter } from "./terminal.js";
9
11
  export interface CliProgramOptions {
10
12
  io?: CapabilitiesCommandIO;
@@ -14,6 +16,8 @@ export interface CliProgramOptions {
14
16
  now?: Date;
15
17
  stderr?: TerminalWriter;
16
18
  suppressCommanderErrors?: boolean;
19
+ updateCommandRunner?: UpdateCommandRunner;
20
+ currentVersion?: string;
17
21
  }
18
22
  export interface CliRunOptions extends CliProgramOptions {
19
23
  stderr?: TerminalWriter;
@@ -25,6 +29,8 @@ export { runAssetOverviewCommand } from "../commands/assets.js";
25
29
  export { runCapabilitiesCommand, runStatusCommand };
26
30
  export { runInitCommand };
27
31
  export { runMarketAssetsCommand, runMarketPriceCommand };
32
+ export { runScreeningIndicatorsCommand, runScreeningRunCommand, runScreeningUniversesCommand, };
28
33
  export { runHoldingBetaCommand, runHoldingCreateCommand, runHoldingGetCommand, runHoldingHistoricalReturnCommand, runHoldingListCommand, runHoldingRenameCommand, runHoldingSetPositionsCommand, runHoldingSetTargetsCommand, runHoldingVarCommand, runWatchlistAddAssetsCommand, runWatchlistCreateCommand, runWatchlistGetCommand, runWatchlistListCommand, runWatchlistRemoveAssetsCommand, runWatchlistRenameCommand, };
29
34
  export { runSkillsInstallCommand };
35
+ export { runUpdateCommand };
30
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,OAAO,EACL,KAAK,qBAAqB,EAE1B,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,EAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAQvE,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;I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E,iBAAsB,GAAG,OAAO,CA0EzE;AAeD,wBAAsB,GAAG,CACvB,IAAI,WAAe,EACnB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAoCD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,CAAC;AACzD,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,GAC7B,CAAC;AACF,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,GAC1B,CAAC;AACF,OAAO,EAAE,uBAAuB,EAAE,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/dist/cli/index.js CHANGED
@@ -6,8 +6,10 @@ import { registerCapabilitiesCommand, runCapabilitiesCommand, } from "../command
6
6
  import { registerMarketCommands, runMarketAssetsCommand, runMarketPriceCommand, } from "../commands/market.js";
7
7
  import { registerInitCommand, runInitCommand, } from "../commands/init.js";
8
8
  import { registerPortfoliosCommands, runHoldingCreateCommand, runHoldingBetaCommand, runHoldingGetCommand, runHoldingHistoricalReturnCommand, runHoldingListCommand, runHoldingRenameCommand, runHoldingSetPositionsCommand, runHoldingSetTargetsCommand, runHoldingVarCommand, runWatchlistAddAssetsCommand, runWatchlistCreateCommand, runWatchlistGetCommand, runWatchlistListCommand, runWatchlistRemoveAssetsCommand, runWatchlistRenameCommand, } from "../commands/portfolios.js";
9
+ import { registerScreeningCommands, runScreeningIndicatorsCommand, runScreeningRunCommand, runScreeningUniversesCommand, } from "../commands/screening.js";
9
10
  import { registerSkillsCommands, runSkillsInstallCommand, } from "../commands/skills.js";
10
11
  import { registerStatusFlag, runStatusCommand, } from "../commands/status.js";
12
+ import { registerUpdateCommand, runUpdateCommand, } from "../commands/update.js";
11
13
  import { buildCliErrorPayload, formatCliErrorMessage, normalizeCliError, shouldEmitJsonError, } from "./errors.js";
12
14
  import { styleErrorMessage } from "./terminal.js";
13
15
  const requirePackage = createRequire(import.meta.url);
@@ -42,6 +44,11 @@ export function createCliProgram(options = {}) {
42
44
  fetch: options.fetch,
43
45
  now: options.now,
44
46
  };
47
+ const screeningContext = {
48
+ io: options.io,
49
+ env: options.env,
50
+ fetch: options.fetch,
51
+ };
45
52
  const skillsContext = {
46
53
  io: options.io,
47
54
  env: options.env,
@@ -50,10 +57,18 @@ export function createCliProgram(options = {}) {
50
57
  io: options.io,
51
58
  env: options.env,
52
59
  };
60
+ const updateContext = {
61
+ io: options.io,
62
+ env: options.env,
63
+ prompt: options.prompt,
64
+ commandRunner: options.updateCommandRunner,
65
+ currentVersion: options.currentVersion ?? CLI_VERSION,
66
+ };
53
67
  program
54
68
  .name("quantbrasil")
55
- .description("Public QuantBrasil CLI for deterministic operations")
69
+ .description("CLI pública do QuantBrasil para operações determinísticas")
56
70
  .version(CLI_VERSION)
71
+ .helpOption("-h, --help", "Exibe ajuda do comando")
57
72
  .exitOverride()
58
73
  .showHelpAfterError()
59
74
  .showSuggestionAfterError();
@@ -65,7 +80,9 @@ export function createCliProgram(options = {}) {
65
80
  registerInitCommand(program, initContext);
66
81
  registerMarketCommands(program, marketContext);
67
82
  registerPortfoliosCommands(program, portfoliosContext);
83
+ registerScreeningCommands(program, screeningContext);
68
84
  registerSkillsCommands(program, skillsContext);
85
+ registerUpdateCommand(program, updateContext);
69
86
  registerStatusFlag(program, statusContext);
70
87
  return program;
71
88
  }
@@ -131,5 +148,7 @@ export { runAssetOverviewCommand } from "../commands/assets.js";
131
148
  export { runCapabilitiesCommand, runStatusCommand };
132
149
  export { runInitCommand };
133
150
  export { runMarketAssetsCommand, runMarketPriceCommand };
151
+ export { runScreeningIndicatorsCommand, runScreeningRunCommand, runScreeningUniversesCommand, };
134
152
  export { runHoldingBetaCommand, runHoldingCreateCommand, runHoldingGetCommand, runHoldingHistoricalReturnCommand, runHoldingListCommand, runHoldingRenameCommand, runHoldingSetPositionsCommand, runHoldingSetTargetsCommand, runHoldingVarCommand, runWatchlistAddAssetsCommand, runWatchlistCreateCommand, runWatchlistGetCommand, runWatchlistListCommand, runWatchlistRemoveAssetsCommand, runWatchlistRenameCommand, };
135
153
  export { runSkillsInstallCommand };
154
+ export { runUpdateCommand };
@@ -1,2 +1,3 @@
1
1
  export declare function promptForSecret(promptLabel: string): Promise<string>;
2
+ export declare function promptForConfirmation(promptLabel: string): Promise<boolean>;
2
3
  //# sourceMappingURL=prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/cli/prompt.ts"],"names":[],"mappings":"AAyBA,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwB1E"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/cli/prompt.ts"],"names":[],"mappings":"AAyBA,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwB1E;AAED,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC,CAmBlB"}
@@ -38,3 +38,20 @@ export async function promptForSecret(promptLabel) {
38
38
  readline.close();
39
39
  }
40
40
  }
41
+ export async function promptForConfirmation(promptLabel) {
42
+ if (!input.isTTY || !output.isTTY) {
43
+ throw createCliConfigError("Confirmação interativa requer um TTY. Use --yes para aplicar a atualização.");
44
+ }
45
+ const readline = createInterface({
46
+ input,
47
+ output,
48
+ terminal: true,
49
+ });
50
+ try {
51
+ const answer = await readline.question(promptLabel);
52
+ return ["s", "sim", "y", "yes"].includes(answer.trim().toLowerCase());
53
+ }
54
+ finally {
55
+ readline.close();
56
+ }
57
+ }
@@ -20,7 +20,16 @@ export interface SkillInstallResult {
20
20
  installed: InstalledSkillTarget[];
21
21
  skipped: SkippedSkillTarget[];
22
22
  }
23
+ export type SkillInstallStatus = "current" | "missing" | "stale" | "skipped";
24
+ export interface SkillInstallTargetStatus extends SkillInstallTarget {
25
+ status: SkillInstallStatus;
26
+ }
27
+ export interface SkillInstallState {
28
+ targets: SkillInstallTargetStatus[];
29
+ needsInstall: boolean;
30
+ }
23
31
  export declare function installBundledSkillEverywhere(env?: NodeJS.ProcessEnv): Promise<SkillInstallResult>;
32
+ export declare function getBundledSkillInstallState(env?: NodeJS.ProcessEnv): Promise<SkillInstallState>;
24
33
  export declare function resolveSkillInstallTargets(env?: NodeJS.ProcessEnv): SkillInstallTarget[];
25
34
  export declare function resolveBundledSkillSourcePath(): string;
26
35
  //# sourceMappingURL=skills.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/cli/skills.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEnE,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,sBAAsB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,sBAAsB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,sBA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MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,wBAAwB,EAAE,CAAC;IACpC,YAAY,EAAE,OAAO,CAAC;CACvB;AAcD,wBAAsB,6BAA6B,CACjD,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,kBAAkB,CAAC,CAmD7B;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,iBAAiB,CAAC,CA0C5B;AAED,wBAAgB,0BAA0B,CACxC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,kBAAkB,EAAE,CAetB;AAED,wBAAgB,6BAA6B,IAAI,MAAM,CAEtD"}
@@ -1,4 +1,5 @@
1
- import { access, cp, mkdir, rm } from "node:fs/promises";
1
+ import { createHash } from "node:crypto";
2
+ import { access, cp, mkdir, readdir, readFile, rm } from "node:fs/promises";
2
3
  import { homedir } from "node:os";
3
4
  import { dirname, join } from "node:path";
4
5
  import { fileURLToPath } from "node:url";
@@ -45,13 +46,46 @@ export async function installBundledSkillEverywhere(env = process.env) {
45
46
  }
46
47
  if (installed.length === 0) {
47
48
  const checkedRoots = targets.map(target => target.rootDir).join(", ");
48
- throw createCliConfigError(`No supported agent clients detected. Checked: ${checkedRoots}.`);
49
+ throw createCliConfigError(`Nenhum cliente de agente compatível detectado. Verificados: ${checkedRoots}.`);
49
50
  }
50
51
  return {
51
52
  installed,
52
53
  skipped,
53
54
  };
54
55
  }
56
+ export async function getBundledSkillInstallState(env = process.env) {
57
+ const bundledSkillPath = resolveBundledSkillSourcePath();
58
+ await assertBundledSkillExists(bundledSkillPath);
59
+ const bundledHash = await hashDirectory(bundledSkillPath);
60
+ const targets = [];
61
+ for (const target of resolveSkillInstallTargets(env)) {
62
+ if (target.id !== AGENT_SKILLS_CONVENTION_ID &&
63
+ !(await pathExists(target.rootDir))) {
64
+ targets.push({
65
+ ...target,
66
+ status: "skipped",
67
+ });
68
+ continue;
69
+ }
70
+ if (!(await pathExists(join(target.installDir, "SKILL.md")))) {
71
+ targets.push({
72
+ ...target,
73
+ status: "missing",
74
+ });
75
+ continue;
76
+ }
77
+ targets.push({
78
+ ...target,
79
+ status: (await hashDirectory(target.installDir)) === bundledHash
80
+ ? "current"
81
+ : "stale",
82
+ });
83
+ }
84
+ return {
85
+ targets,
86
+ needsInstall: targets.some(target => target.status === "missing" || target.status === "stale"),
87
+ };
88
+ }
55
89
  export function resolveSkillInstallTargets(env = process.env) {
56
90
  const home = resolveCliHomeDirectory(env);
57
91
  return SUPPORTED_SKILL_CLIENTS.map(client => {
@@ -74,12 +108,42 @@ async function assertBundledSkillExists(skillPath) {
74
108
  if (await pathExists(skillEntryPath)) {
75
109
  return;
76
110
  }
77
- throw createCliConfigError(`Bundled QuantBrasil skill not found at ${skillEntryPath}. Reinstall the CLI package.`);
111
+ throw createCliConfigError(`Skill QuantBrasil empacotada não encontrada em ${skillEntryPath}. Reinstale o pacote da CLI.`);
112
+ }
113
+ async function hashDirectory(directory) {
114
+ const hash = createHash("sha256");
115
+ const files = await collectDirectoryFiles(directory);
116
+ for (const file of files) {
117
+ hash.update(file.relativePath);
118
+ hash.update("\0");
119
+ hash.update(await readFile(file.fullPath));
120
+ hash.update("\0");
121
+ }
122
+ return hash.digest("hex");
123
+ }
124
+ async function collectDirectoryFiles(current, relativePrefix = "") {
125
+ const entries = await readdir(current, { withFileTypes: true });
126
+ const sortedEntries = entries.sort((left, right) => left.name.localeCompare(right.name));
127
+ const files = [];
128
+ for (const entry of sortedEntries) {
129
+ const fullPath = join(current, entry.name);
130
+ const relativePath = relativePrefix
131
+ ? `${relativePrefix}/${entry.name}`
132
+ : entry.name;
133
+ if (entry.isDirectory()) {
134
+ files.push(...(await collectDirectoryFiles(fullPath, relativePath)));
135
+ continue;
136
+ }
137
+ if (entry.isFile()) {
138
+ files.push({ fullPath, relativePath });
139
+ }
140
+ }
141
+ return files;
78
142
  }
79
143
  function resolveCliHomeDirectory(env) {
80
144
  const home = env.HOME?.trim() || homedir();
81
145
  if (!home) {
82
- throw createCliConfigError("Could not resolve the HOME directory for skill install.");
146
+ throw createCliConfigError("Não foi possível resolver o diretório HOME para instalar a skill.");
83
147
  }
84
148
  return home;
85
149
  }
@@ -0,0 +1,120 @@
1
+ import { Command } from "commander";
2
+ import type { JsonValue } from "../vendor/core/index.js";
3
+ import { type CliInvokeContext } from "../cli/client.js";
4
+ import { type TerminalWriter } from "../cli/terminal.js";
5
+ export interface ScreeningCommandIO {
6
+ stdout: TerminalWriter;
7
+ }
8
+ export interface ScreeningUniversesCommandOptions {
9
+ json?: boolean;
10
+ }
11
+ export interface ScreeningIndicatorsCommandOptions {
12
+ json?: boolean;
13
+ }
14
+ export interface ScreeningRunCommandOptions {
15
+ system?: string;
16
+ watchlist?: string;
17
+ holding?: string;
18
+ queryFile?: string;
19
+ limit?: string;
20
+ sort?: string;
21
+ json?: boolean;
22
+ }
23
+ export interface ScreeningUniverseOut {
24
+ [key: string]: JsonValue;
25
+ id: number;
26
+ name: string;
27
+ kind: "SYSTEM" | "WATCHLIST" | "HOLDING";
28
+ slug: string | null;
29
+ symbol_count: number;
30
+ }
31
+ export interface ScreeningUniversesResponse {
32
+ [key: string]: JsonValue;
33
+ ok: boolean;
34
+ system: ScreeningUniverseOut[];
35
+ watchlists: ScreeningUniverseOut[];
36
+ holdings: ScreeningUniverseOut[];
37
+ total: number;
38
+ }
39
+ export type ScreeningIndicatorScalar = string | number | boolean;
40
+ export interface ScreeningIndicatorParamOut {
41
+ [key: string]: JsonValue;
42
+ name: string;
43
+ type: "integer" | "number" | "enum" | "string" | "boolean";
44
+ required: boolean;
45
+ default: ScreeningIndicatorScalar | null;
46
+ description: string;
47
+ enum_values: string[] | null;
48
+ examples: ScreeningIndicatorScalar[];
49
+ }
50
+ export interface ScreeningIndicatorRef {
51
+ [key: string]: JsonValue;
52
+ name: string;
53
+ timeframe: string;
54
+ offset: number;
55
+ params: Record<string, JsonValue>;
56
+ }
57
+ export interface ScreeningIndicatorExampleOut {
58
+ [key: string]: JsonValue;
59
+ label: string;
60
+ description: string;
61
+ indicator: ScreeningIndicatorRef;
62
+ }
63
+ export interface ScreeningIndicatorOut {
64
+ [key: string]: JsonValue;
65
+ name: string;
66
+ display_name: string;
67
+ description: string;
68
+ timeframes: string[];
69
+ params: ScreeningIndicatorParamOut[];
70
+ examples: ScreeningIndicatorExampleOut[];
71
+ }
72
+ export interface ScreeningIndicatorsResponse {
73
+ [key: string]: JsonValue;
74
+ ok: boolean;
75
+ indicators: ScreeningIndicatorOut[];
76
+ operators: string[];
77
+ }
78
+ export interface IndicatorResult {
79
+ [key: string]: JsonValue;
80
+ value: number;
81
+ display_name: string;
82
+ unit: string | null;
83
+ context: {
84
+ [key: string]: JsonValue;
85
+ } | null;
86
+ }
87
+ export interface ScreenerResultItem {
88
+ [key: string]: JsonValue;
89
+ ticker: string;
90
+ price: number;
91
+ indicators: Record<string, IndicatorResult>;
92
+ }
93
+ export interface ScreenerResponse {
94
+ [key: string]: JsonValue;
95
+ count: number;
96
+ results: ScreenerResultItem[];
97
+ }
98
+ export interface ScreeningRunResponse {
99
+ [key: string]: JsonValue;
100
+ ok: boolean;
101
+ summary_markdown: string;
102
+ universe: ScreeningUniverseOut;
103
+ result: ScreenerResponse;
104
+ }
105
+ export interface ScreeningCommandContext extends CliInvokeContext {
106
+ io?: ScreeningCommandIO;
107
+ }
108
+ type JsonRecord = {
109
+ [key: string]: JsonValue;
110
+ };
111
+ export declare function registerScreeningCommands(program: Command, context?: ScreeningCommandContext): void;
112
+ export declare function runScreeningUniversesCommand(options: ScreeningUniversesCommandOptions, context?: ScreeningCommandContext): Promise<void>;
113
+ export declare function runScreeningIndicatorsCommand(options: ScreeningIndicatorsCommandOptions, context?: ScreeningCommandContext): Promise<void>;
114
+ export declare function runScreeningRunCommand(options: ScreeningRunCommandOptions, context?: ScreeningCommandContext): Promise<void>;
115
+ export declare function buildScreeningRunInput(options: ScreeningRunCommandOptions): Promise<JsonRecord>;
116
+ export declare function formatScreeningUniversesHuman(data: ScreeningUniversesResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
117
+ export declare function formatScreeningIndicatorsHuman(data: ScreeningIndicatorsResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
118
+ export declare function formatScreeningRunHuman(data: ScreeningRunResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
119
+ export {};
120
+ //# sourceMappingURL=screening.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screening.d.ts","sourceRoot":"","sources":["../../src/commands/screening.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,gCAAgC;IAC/C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,iCAAiC;IAChD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,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