@aidran/cli 0.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.
package/LICENSE ADDED
@@ -0,0 +1,200 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and offer to
167
+ others to charge a fee for, or accept any liability or obligation
168
+ consistent with this License. However, in accepting such obligations,
169
+ You may act only on Your own behalf and on Your sole responsibility,
170
+ not on behalf of any other Contributor, and only if You agree to
171
+ indemnify, defend, and hold each Contributor harmless for any
172
+ liability incurred by, or claims asserted against, such Contributor
173
+ by reason of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ APPENDIX: How to apply the Apache License to your work.
178
+
179
+ To apply the Apache License to your work, attach the following
180
+ boilerplate notice, with the fields enclosed by brackets "[]"
181
+ replaced with your own identifying information. (Don't include
182
+ the brackets!) The text should be enclosed in the appropriate
183
+ comment syntax for the file format. We also recommend that a
184
+ file or class name and description of purpose be included on the
185
+ same "printed page" as the copyright notice for easier
186
+ identification within third-party archives.
187
+
188
+ Copyright 2026 AIDRAN LLC
189
+
190
+ Licensed under the Apache License, Version 2.0 (the "License");
191
+ you may not use this file except in compliance with the License.
192
+ You may obtain a copy of the License at
193
+
194
+ http://www.apache.org/licenses/LICENSE-2.0
195
+
196
+ Unless required by applicable law or agreed to in writing, software
197
+ distributed under the License is distributed on an "AS IS" BASIS,
198
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
+ See the License for the specific language governing permissions and
200
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ AIDRAN Platform Scaffold
2
+ Copyright 2026 AIDRAN LLC
3
+
4
+ This product includes software developed by AIDRAN LLC (https://aidran.ai).
5
+
6
+ This repository is a curated public scaffold of the AIDRAN discourse
7
+ intelligence platform. The components that define AIDRAN's editorial voice
8
+ and quality bar are intentionally omitted and remain proprietary to AIDRAN
9
+ LLC. See NOTICE.md for the full list of omitted components.
10
+
11
+ AIDRAN(TM) is a trademark of AIDRAN LLC. The Apache License 2.0 does not
12
+ grant rights in the AIDRAN trademark. See TRADEMARKS.md.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @aidran/cli
2
+
3
+ CLI for the [AIDRAN](https://aidran.ai) discourse-intelligence platform. Applies the `@aidran/db` migrations to your Postgres database and scaffolds the minimal config needed to consume AIDRAN packages.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ # As a one-off (no install):
9
+ npx @aidran/cli help
10
+
11
+ # Or as a project dev-dependency:
12
+ pnpm add -D @aidran/cli
13
+ npm install --save-dev @aidran/cli
14
+ ```
15
+
16
+ ## Commands
17
+
18
+ ```sh
19
+ aidran init # Write .env.example and drizzle.config.ts to cwd
20
+ aidran migrate # Apply @aidran/db migrations to $DATABASE_URL
21
+ aidran verify # Sanity-check the schema against $DATABASE_URL
22
+ aidran help # Show usage
23
+ ```
24
+
25
+ ## Zero-to-running quickstart
26
+
27
+ ```sh
28
+ mkdir my-aidran-project && cd my-aidran-project
29
+ npx @aidran/cli init # writes .env.example + drizzle.config.ts
30
+ cp .env.example .env # fill in DATABASE_URL
31
+ DATABASE_URL='postgres://...' npx @aidran/cli migrate
32
+ DATABASE_URL='postgres://...' npx @aidran/cli verify
33
+ ```
34
+
35
+ After `migrate`, your Postgres has all the AIDRAN corpus tables (`records`, `stories`, `signals`, `topics`, etc.). You can then `import { records, stories } from '@aidran/db'` in your application and query them with full type safety via Drizzle.
36
+
37
+ ## What it ships
38
+
39
+ The package bundles the AIDRAN migrations folder (the same SQL the production system runs) and uses `drizzle-orm/node-postgres/migrator` to apply them. Idempotent — drizzle tracks applied migrations in a `drizzle.__drizzle_migrations` table.
40
+
41
+ ## Status
42
+
43
+ Part of the AIDRAN platform public reference implementation. Published from the [`AIDRAN/aidran`](https://github.com/AIDRAN/aidran) monorepo. See [`NOTICE.md`](https://github.com/AIDRAN/aidran/blob/main/NOTICE.md) for the components intentionally omitted from the public reference.
44
+
45
+ ## License
46
+
47
+ Apache-2.0.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @aidran/cli — entry point.
4
+ *
5
+ * Subcommands:
6
+ * aidran migrate Apply @aidran/db migrations to $DATABASE_URL
7
+ * aidran init Write a starter .env.example and drizzle.config.ts to cwd
8
+ * aidran verify Check DATABASE_URL connectivity + count expected tables
9
+ * aidran help Show usage
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG"}
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @aidran/cli — entry point.
4
+ *
5
+ * Subcommands:
6
+ * aidran migrate Apply @aidran/db migrations to $DATABASE_URL
7
+ * aidran init Write a starter .env.example and drizzle.config.ts to cwd
8
+ * aidran verify Check DATABASE_URL connectivity + count expected tables
9
+ * aidran help Show usage
10
+ */
11
+ import { runMigrate } from './migrate.js';
12
+ import { runInit } from './init.js';
13
+ import { runVerify } from './verify.js';
14
+ const HELP = `aidran — AIDRAN platform CLI
15
+
16
+ Usage:
17
+ aidran <command>
18
+
19
+ Commands:
20
+ init Scaffold .env.example and drizzle.config.ts in the current directory
21
+ migrate Apply @aidran/db migrations to the database at $DATABASE_URL
22
+ verify Confirm $DATABASE_URL is reachable and required tables exist
23
+ help Show this help text
24
+
25
+ Environment:
26
+ DATABASE_URL Postgres connection string used by 'migrate' and 'verify'
27
+ `;
28
+ const [, , command] = process.argv;
29
+ const commands = {
30
+ init: runInit,
31
+ migrate: runMigrate,
32
+ verify: runVerify,
33
+ help: async () => {
34
+ process.stdout.write(HELP);
35
+ },
36
+ '--help': async () => {
37
+ process.stdout.write(HELP);
38
+ },
39
+ '-h': async () => {
40
+ process.stdout.write(HELP);
41
+ },
42
+ };
43
+ const handler = command ? commands[command] : commands.help;
44
+ if (!handler) {
45
+ process.stderr.write(`aidran: unknown command '${command}'\n\n${HELP}`);
46
+ process.exit(1);
47
+ }
48
+ handler().catch((err) => {
49
+ if (err instanceof Error) {
50
+ process.stderr.write(`aidran: ${err.message}\n`);
51
+ }
52
+ else {
53
+ process.stderr.write(`aidran: ${String(err)}\n`);
54
+ }
55
+ process.exit(1);
56
+ });
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,IAAI,GAAG;;;;;;;;;;;;;CAaZ,CAAC;AAEF,MAAM,CAAC,EAAE,AAAD,EAAG,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;AAEnC,MAAM,QAAQ,GAAwC;IACpD,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,KAAK,IAAI,EAAE;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,QAAQ,EAAE,KAAK,IAAI,EAAE;QACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,EAAE,KAAK,IAAI,EAAE;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF,CAAC;AAEF,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAE5D,IAAI,CAAC,OAAO,EAAE,CAAC;IACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,OAAO,QAAQ,IAAI,EAAE,CAAC,CAAC;IACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC/B,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/dist/init.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `aidran init` — scaffold a starter setup in the user's current directory:
3
+ * .env.example for the required environment variables and drizzle.config.ts
4
+ * wired to the installed @aidran/db schema. Refuses to overwrite existing
5
+ * files; the user must remove them first if they want a fresh scaffold.
6
+ */
7
+ export declare function runInit(): Promise<void>;
8
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoDH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAW7C"}
package/dist/init.js ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * `aidran init` — scaffold a starter setup in the user's current directory:
3
+ * .env.example for the required environment variables and drizzle.config.ts
4
+ * wired to the installed @aidran/db schema. Refuses to overwrite existing
5
+ * files; the user must remove them first if they want a fresh scaffold.
6
+ */
7
+ import { writeFile, access } from 'node:fs/promises';
8
+ import { join } from 'node:path';
9
+ const ENV_EXAMPLE = `# Postgres connection string used by 'aidran migrate' and any code that
10
+ # imports @aidran/db's Drizzle schema.
11
+ DATABASE_URL=postgres://aidran:aidran@localhost:5432/aidran
12
+
13
+ # API key required by the reference delivery API stub when reading from the
14
+ # corpus. Generate any opaque string — clients send it as 'Authorization: Bearer <key>'.
15
+ AIDRAN_API_KEY=replace-me-with-a-long-random-string
16
+ `;
17
+ const DRIZZLE_CONFIG = `import { defineConfig } from 'drizzle-kit';
18
+
19
+ /**
20
+ * Drizzle Kit configuration that points at the installed @aidran/db schema.
21
+ * Use this if you want to extend the AIDRAN schema with your own tables and
22
+ * generate additive migrations. The base AIDRAN migrations are already
23
+ * applied via 'aidran migrate' from the @aidran/db package itself.
24
+ */
25
+ export default defineConfig({
26
+ schema: './node_modules/@aidran/db/dist/schema/index.js',
27
+ out: './migrations',
28
+ dialect: 'postgresql',
29
+ dbCredentials: {
30
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
31
+ url: process.env.DATABASE_URL!,
32
+ },
33
+ });
34
+ `;
35
+ async function exists(path) {
36
+ try {
37
+ await access(path);
38
+ return true;
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
44
+ async function writeIfMissing(path, content) {
45
+ if (await exists(path)) {
46
+ process.stdout.write(`aidran: skipped ${path} (already exists)\n`);
47
+ return 'skipped';
48
+ }
49
+ await writeFile(path, content, 'utf8');
50
+ process.stdout.write(`aidran: wrote ${path}\n`);
51
+ return 'wrote';
52
+ }
53
+ export async function runInit() {
54
+ const cwd = process.cwd();
55
+ await writeIfMissing(join(cwd, '.env.example'), ENV_EXAMPLE);
56
+ await writeIfMissing(join(cwd, 'drizzle.config.ts'), DRIZZLE_CONFIG);
57
+ process.stdout.write('\naidran: scaffold complete. Next:\n' +
58
+ ' 1. cp .env.example .env (fill in DATABASE_URL and AIDRAN_API_KEY)\n' +
59
+ ' 2. aidran migrate (creates AIDRAN tables in your postgres)\n' +
60
+ ' 3. aidran verify (sanity-check the schema)\n');
61
+ }
62
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,WAAW,GAAG;;;;;;;CAOnB,CAAC;AAEF,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;CAiBtB,CAAC;AAEF,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,OAAe;IACzD,IAAI,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,IAAI,qBAAqB,CAAC,CAAC;QACnE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,WAAW,CAAC,CAAC;IAC7D,MAAM,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,EAAE,cAAc,CAAC,CAAC;IAErE,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,sCAAsC;QACpC,wEAAwE;QACxE,wEAAwE;QACxE,yDAAyD,CAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `aidran migrate` — apply the bundled @aidran/db migrations to the database
3
+ * at $DATABASE_URL using drizzle-orm's node-postgres migrator. Idempotent;
4
+ * drizzle tracks applied migrations in a `drizzle.__drizzle_migrations` table.
5
+ */
6
+ export declare function runMigrate(): Promise<void>;
7
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAiBhD"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * `aidran migrate` — apply the bundled @aidran/db migrations to the database
3
+ * at $DATABASE_URL using drizzle-orm's node-postgres migrator. Idempotent;
4
+ * drizzle tracks applied migrations in a `drizzle.__drizzle_migrations` table.
5
+ */
6
+ import { Pool } from 'pg';
7
+ import { drizzle } from 'drizzle-orm/node-postgres';
8
+ import { migrate } from 'drizzle-orm/node-postgres/migrator';
9
+ import { migrationsFolder } from '@aidran/db/migrations-path';
10
+ export async function runMigrate() {
11
+ const url = process.env.DATABASE_URL;
12
+ if (!url) {
13
+ throw new Error('DATABASE_URL is not set. Add it to your environment or .env file.');
14
+ }
15
+ process.stdout.write(`aidran: applying migrations from ${migrationsFolder}\n`);
16
+ const pool = new Pool({ connectionString: url });
17
+ const db = drizzle(pool);
18
+ try {
19
+ await migrate(db, { migrationsFolder });
20
+ process.stdout.write('aidran: migrations applied successfully\n');
21
+ }
22
+ finally {
23
+ await pool.end();
24
+ }
25
+ }
26
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACrC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,gBAAgB,IAAI,CAAC,CAAC;IAE/E,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACpE,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `aidran verify` — sanity check that $DATABASE_URL is reachable and the
3
+ * core AIDRAN tables exist. Cheap pre-flight before running ingestion or the
4
+ * delivery API.
5
+ */
6
+ export declare function runVerify(): Promise<void>;
7
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CA6B/C"}
package/dist/verify.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `aidran verify` — sanity check that $DATABASE_URL is reachable and the
3
+ * core AIDRAN tables exist. Cheap pre-flight before running ingestion or the
4
+ * delivery API.
5
+ */
6
+ import { Pool } from 'pg';
7
+ const EXPECTED_TABLES = [
8
+ 'records',
9
+ 'stories',
10
+ 'signals',
11
+ 'story_arcs',
12
+ 'topics',
13
+ 'entities',
14
+ 'search_sync_checkpoints',
15
+ ];
16
+ export async function runVerify() {
17
+ const url = process.env.DATABASE_URL;
18
+ if (!url) {
19
+ throw new Error('DATABASE_URL is not set.');
20
+ }
21
+ const pool = new Pool({ connectionString: url });
22
+ try {
23
+ const { rows } = await pool.query(`SELECT table_name FROM information_schema.tables
24
+ WHERE table_schema = 'public' AND table_name = ANY($1::text[])`, [EXPECTED_TABLES]);
25
+ const found = new Set(rows.map((r) => r.table_name));
26
+ const missing = EXPECTED_TABLES.filter((t) => !found.has(t));
27
+ process.stdout.write(`aidran: connected to ${url.replace(/:[^:@]+@/, ':***@')}\n`);
28
+ process.stdout.write(`aidran: found ${found.size}/${EXPECTED_TABLES.length} expected tables\n`);
29
+ if (missing.length > 0) {
30
+ process.stdout.write(`aidran: missing tables: ${missing.join(', ')}\n`);
31
+ process.stdout.write("aidran: run 'aidran migrate' to apply schema\n");
32
+ process.exit(1);
33
+ }
34
+ process.stdout.write('aidran: schema looks healthy ✓\n');
35
+ }
36
+ finally {
37
+ await pool.end();
38
+ }
39
+ }
40
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,MAAM,eAAe,GAAG;IACtB,SAAS;IACT,SAAS;IACT,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,yBAAyB;CACjB,CAAC;AAEX,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACrC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAC/B;sEACgE,EAChE,CAAC,eAAe,CAAC,CAClB,CAAC;QACF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACrD,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE7D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACnF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,KAAK,CAAC,IAAI,IAAI,eAAe,CAAC,MAAM,oBAAoB,CAAC,CAAC;QAEhG,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;YACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC3D,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@aidran/cli",
3
+ "version": "0.1.0",
4
+ "description": "AIDRAN — CLI for applying the @aidran/db migrations and scaffolding consumer projects",
5
+ "keywords": [
6
+ "aidran",
7
+ "discourse-intelligence",
8
+ "cli",
9
+ "postgres",
10
+ "drizzle",
11
+ "migrations"
12
+ ],
13
+ "homepage": "https://github.com/AIDRAN/aidran#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/AIDRAN/aidran/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/AIDRAN/aidran.git",
20
+ "directory": "packages/cli"
21
+ },
22
+ "license": "Apache-2.0",
23
+ "author": "AIDRAN contributors",
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "bin": {
28
+ "aidran": "./dist/index.js"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE",
34
+ "NOTICE"
35
+ ],
36
+ "dependencies": {
37
+ "drizzle-orm": "^0.36.0",
38
+ "pg": "^8.13.0",
39
+ "@aidran/db": "0.2.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^22.9.0",
43
+ "@types/pg": "^8.11.10",
44
+ "typescript": "^5.7.2"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "provenance": true
49
+ },
50
+ "engines": {
51
+ "node": ">=22.0.0"
52
+ },
53
+ "scripts": {
54
+ "typecheck": "tsc --noEmit",
55
+ "build": "tsc && chmod +x dist/index.js"
56
+ }
57
+ }