edgar-cli 0.1.4 → 0.2.2

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.
package/README.md CHANGED
@@ -1,141 +1,11 @@
1
1
  # edgar-cli
2
2
 
3
- Agent-friendly SEC EDGAR CLI for filings and company facts.
3
+ Go-native SEC EDGAR CLI for `npx` workflows.
4
4
 
5
- ## Features
6
-
7
- - `npx`-friendly Node/TypeScript package (no Python runtime needed)
8
- - JSON envelope output by default for stable automation
9
- - Strict SEC identity enforcement (`--user-agent` or `EDGAR_USER_AGENT`)
10
- - Core commands:
11
- - `resolve`
12
- - `filings list`
13
- - `filings get`
14
- - `facts get`
15
- - `research sync`
16
- - `research ask`
17
-
18
- ## Install / Run
5
+ This package is a small Node launcher that dispatches to a prebuilt native Go binary for the current platform.
19
6
 
20
7
  ```bash
21
8
  npx edgar-cli --help
22
9
  ```
23
10
 
24
- Local development:
25
-
26
- ```bash
27
- npm install
28
- npm run build
29
- node dist/cli.js --help
30
- ```
31
-
32
- ## SEC Identity Requirement
33
-
34
- SEC endpoints require declared automated access identity.
35
-
36
- Use either:
37
-
38
- ```bash
39
- export EDGAR_USER_AGENT="Your Name your.email@example.com"
40
- ```
41
-
42
- Or pass per command:
43
-
44
- ```bash
45
- npx edgar-cli --user-agent "Your Name your.email@example.com" resolve AAPL
46
- ```
47
-
48
- If identity is missing, commands fail with `IDENTITY_REQUIRED`.
49
-
50
- ## Examples
51
-
52
- ```bash
53
- # Resolve ticker -> canonical SEC identity mapping
54
- npx edgar-cli --user-agent "Your Name your.email@example.com" resolve AAPL
55
-
56
- # List recent 10-K filings
57
- npx edgar-cli --user-agent "Your Name your.email@example.com" filings list --id AAPL --form 10-K --query-limit 5
58
-
59
- # Get filing document URL by accession
60
- npx edgar-cli --user-agent "Your Name your.email@example.com" filings get --id AAPL --accession 0000320193-26-000006 --format url
61
-
62
- # Get filing converted to Markdown
63
- npx edgar-cli --user-agent "Your Name your.email@example.com" filings get --id AAPL --accession 0000320193-26-000006 --format markdown
64
-
65
- # Get concept data (latest per unit)
66
- npx edgar-cli --user-agent "Your Name your.email@example.com" facts get --id AAPL --taxonomy us-gaap --concept Revenues --latest
67
-
68
- # Query explicit local docs (repeat --doc or pass --manifest)
69
- npx edgar-cli research ask "board resignation details" --doc ./cache/nvda-8k.md --top-k 5
70
-
71
- # Build a deterministic cached corpus for a ticker/profile
72
- npx edgar-cli --user-agent "Your Name your.email@example.com" research sync --id NVDA --profile core
73
-
74
- # Query by ticker against cached corpus (auto-syncs on cache miss)
75
- npx edgar-cli --user-agent "Your Name your.email@example.com" research ask "what changed on the board?" --id NVDA --profile core
76
-
77
- # Query latest filing(s) in one shot: discover -> fetch/cache -> search
78
- npx edgar-cli --user-agent "Your Name your.email@example.com" research ask "gross margin drivers" --id AAPL --form 10-Q --latest 1
79
- ```
80
-
81
- ## Research Profiles and Cache
82
-
83
- `research sync` and `research ask --id` use deterministic filing profiles:
84
-
85
- - `core`: latest 1x `10-K`, latest 3x `10-Q`, and recent `8-K` (last 180 days, up to 12)
86
- - `events`: recent `8-K` (last 365 days, up to 24)
87
- - `financials`: latest 2x `10-K` and latest 6x `10-Q`
88
-
89
- By default, cached corpora are stored in:
90
-
91
- - `$EDGAR_CACHE_DIR` (if set), else
92
- - `$XDG_CACHE_HOME/edgar-cli` (if set), else
93
- - `~/.cache/edgar-cli`
94
-
95
- Override per command with `--cache-dir`.
96
-
97
- When using `research ask --id`, you can also scope discovery directly:
98
-
99
- - `--form <form>` to filter filings by form type (e.g. `10-Q`)
100
- - `--latest <n>` to limit selection to the latest N filings after filters
101
-
102
- ## Output Contract (default)
103
-
104
- All JSON-mode commands emit:
105
-
106
- ```json
107
- {
108
- "ok": true,
109
- "command": "resolve",
110
- "provider": "sec",
111
- "data": {},
112
- "error": null,
113
- "meta": {
114
- "timestamp": "2026-02-11T00:00:00Z",
115
- "output_schema": "v1",
116
- "view": "summary"
117
- }
118
- }
119
- ```
120
-
121
- ## Compliance Notes
122
-
123
- - This CLI targets SEC-hosted endpoints only in V0.
124
- - Respect SEC fair-access guidance and use a valid identity in your user-agent.
125
-
126
- References:
127
-
128
- - [SEC Developer](https://www.sec.gov/developer)
129
- - [SEC Webmaster FAQ: code support](https://www.sec.gov/os/webmaster-faq#code-support)
130
-
131
- ## Security
132
-
133
- See [`SECURITY.md`](SECURITY.md) for vulnerability reporting guidance.
134
-
135
- ## Development
136
-
137
- ```bash
138
- npm run typecheck
139
- npm run test
140
- npm run build
141
- ```
11
+ See the repository README for command examples and compliance notes.
@@ -0,0 +1,118 @@
1
+ const { spawnSync } = require("node:child_process");
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
+
5
+ const NATIVE_TARGETS = {
6
+ "darwin-arm64": {
7
+ packageName: "edgar-cli-darwin-arm64",
8
+ binaryRelPath: "bin/edgar"
9
+ },
10
+ "linux-x64": {
11
+ packageName: "edgar-cli-linux-x64",
12
+ binaryRelPath: "bin/edgar"
13
+ }
14
+ };
15
+
16
+ function targetKey(platform, arch) {
17
+ return `${platform}-${arch}`;
18
+ }
19
+
20
+ function resolveNativeBinary({
21
+ platform = process.platform,
22
+ arch = process.arch,
23
+ requireResolve = require.resolve,
24
+ exists = fs.existsSync,
25
+ baseDir = __dirname
26
+ } = {}) {
27
+ const key = targetKey(platform, arch);
28
+ const spec = NATIVE_TARGETS[key];
29
+
30
+ if (!spec) {
31
+ return {
32
+ supported: false,
33
+ key,
34
+ packageName: null,
35
+ binaryPath: null
36
+ };
37
+ }
38
+
39
+ const localNodeModulesBinary = path.resolve(
40
+ baseDir,
41
+ "..",
42
+ "node_modules",
43
+ spec.packageName,
44
+ spec.binaryRelPath
45
+ );
46
+ if (exists(localNodeModulesBinary)) {
47
+ return {
48
+ supported: true,
49
+ key,
50
+ packageName: spec.packageName,
51
+ binaryPath: localNodeModulesBinary
52
+ };
53
+ }
54
+
55
+ try {
56
+ const binaryPath = requireResolve(`${spec.packageName}/${spec.binaryRelPath}`);
57
+
58
+ return {
59
+ supported: true,
60
+ key,
61
+ packageName: spec.packageName,
62
+ binaryPath
63
+ };
64
+ } catch (error) {
65
+ if (error && error.code === "MODULE_NOT_FOUND") {
66
+ return {
67
+ supported: true,
68
+ key,
69
+ packageName: spec.packageName,
70
+ binaryPath: null
71
+ };
72
+ }
73
+ throw error;
74
+ }
75
+ }
76
+
77
+ function runEdgar({
78
+ argv,
79
+ env = process.env,
80
+ spawn = spawnSync,
81
+ stderr = process.stderr,
82
+ platform = process.platform,
83
+ arch = process.arch,
84
+ resolveNative = resolveNativeBinary
85
+ }) {
86
+ const native = resolveNative({ platform, arch });
87
+
88
+ if (!native.supported) {
89
+ stderr.write(`edgar-cli native runtime is not available for ${native.key}.\n`);
90
+ return 1;
91
+ }
92
+
93
+ if (!native.binaryPath) {
94
+ stderr.write(`edgar-cli native runtime package missing: ${native.packageName}\n`);
95
+ stderr.write("Reinstall with optional dependencies enabled, then retry `npx edgar-cli --help`.\n");
96
+ return 1;
97
+ }
98
+
99
+ const result = spawn(native.binaryPath, argv, { stdio: "inherit", env });
100
+ if (result.error) {
101
+ stderr.write(`edgar-cli native launcher failed: ${result.error.message}\n`);
102
+ return 1;
103
+ }
104
+ if (typeof result.status === "number") {
105
+ return result.status;
106
+ }
107
+ if (result.signal) {
108
+ stderr.write(`edgar-cli native launcher terminated by signal ${result.signal}\n`);
109
+ return 1;
110
+ }
111
+ return 1;
112
+ }
113
+
114
+ module.exports = {
115
+ NATIVE_TARGETS,
116
+ resolveNativeBinary,
117
+ runEdgar
118
+ };
package/bin/edgar.cjs ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { runEdgar } = require("./edgar-lib.cjs");
4
+
5
+ const exitCode = runEdgar({ argv: process.argv.slice(2) });
6
+ process.exit(exitCode);
package/package.json CHANGED
@@ -1,63 +1,49 @@
1
1
  {
2
2
  "name": "edgar-cli",
3
- "version": "0.1.4",
4
- "description": "Agent-friendly SEC EDGAR CLI",
3
+ "version": "0.2.2",
4
+ "description": "Go-native SEC EDGAR CLI for npx",
5
5
  "license": "MIT",
6
- "type": "module",
6
+ "type": "commonjs",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
10
  "bin": {
11
- "edgar-cli": "dist/cli.js",
12
- "edgar": "dist/cli.js"
11
+ "edgar-cli": "bin/edgar.cjs",
12
+ "edgar": "bin/edgar.cjs"
13
13
  },
14
14
  "files": [
15
- "dist",
16
- "README.md",
17
- "LICENSE"
15
+ "bin",
16
+ "README.md"
18
17
  ],
19
18
  "engines": {
20
19
  "node": ">=18"
21
20
  },
22
21
  "repository": {
23
22
  "type": "git",
24
- "url": "git+https://github.com/finlayi/edgar-cli.git"
23
+ "url": "git+https://github.com/finlayi/edgar-cli.git",
24
+ "directory": "npm"
25
25
  },
26
26
  "homepage": "https://github.com/finlayi/edgar-cli#readme",
27
27
  "bugs": {
28
28
  "url": "https://github.com/finlayi/edgar-cli/issues"
29
29
  },
30
- "scripts": {
31
- "build": "tsc -p tsconfig.json",
32
- "dev": "tsx src/cli.ts",
33
- "test": "vitest run",
34
- "lint": "eslint . --ext .ts",
35
- "typecheck": "tsc --noEmit"
36
- },
37
30
  "keywords": [
38
31
  "edgar",
39
32
  "sec",
40
33
  "cli",
41
34
  "npx",
42
- "filings"
35
+ "filings",
36
+ "go",
37
+ "native"
43
38
  ],
44
- "dependencies": {
45
- "@joplin/turndown-plugin-gfm": "^1.0.64",
46
- "commander": "^14.0.1",
47
- "p-limit": "^7.1.1",
48
- "turndown": "^7.2.2",
49
- "zod": "^4.1.5"
39
+ "optionalDependencies": {
40
+ "edgar-cli-darwin-arm64": "0.2.2",
41
+ "edgar-cli-linux-x64": "0.2.2"
50
42
  },
51
- "devDependencies": {
52
- "@types/node": "^22.13.9",
53
- "@types/turndown": "^5.0.6",
54
- "@typescript-eslint/eslint-plugin": "^8.44.0",
55
- "@typescript-eslint/parser": "^8.44.0",
56
- "eslint": "^8.57.1",
57
- "nock": "^14.0.10",
58
- "prettier": "^3.6.2",
59
- "tsx": "^4.20.5",
60
- "typescript": "^5.9.2",
61
- "vitest": "^3.2.4"
43
+ "scripts": {
44
+ "build:native": "node scripts/build-native.cjs",
45
+ "sync:versions": "node scripts/sync-platform-versions.cjs",
46
+ "test:versions": "node scripts/sync-platform-versions.cjs --check",
47
+ "test": "npm run test:versions && node --test test/*.test.cjs"
62
48
  }
63
49
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Ian Finlay
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/cli.d.ts DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- interface CliIo {
4
- stdout: (message: string) => void;
5
- stderr: (message: string) => void;
6
- env: NodeJS.ProcessEnv;
7
- }
8
- export declare function buildProgram(io: CliIo): Command;
9
- export declare function runCli(argv: string[], io?: CliIo): Promise<number>;
10
- export {};