@adhd/agent-store-prompts 2.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 (67) hide show
  1. package/drizzle/0000_third_nitro.sql +19 -0
  2. package/drizzle/0001_agents_and_taxonomy.sql +26 -0
  3. package/drizzle/0002_agent_components_junction.sql +13 -0
  4. package/drizzle/0003_usecase_context_rules.sql +31 -0
  5. package/drizzle/0004_composed_prompts.sql +10 -0
  6. package/drizzle/0005_warm_norman_osborn.sql +48 -0
  7. package/drizzle/0006_component_head_version_split.sql +78 -0
  8. package/drizzle/meta/0000_snapshot.json +137 -0
  9. package/drizzle/meta/0001_snapshot.json +302 -0
  10. package/drizzle/meta/0002_snapshot.json +381 -0
  11. package/drizzle/meta/0004_snapshot.json +594 -0
  12. package/drizzle/meta/0005_snapshot.json +594 -0
  13. package/drizzle/meta/0006_snapshot.json +672 -0
  14. package/drizzle/meta/_journal.json +55 -0
  15. package/package.json +51 -0
  16. package/src/db/client.d.ts +7 -0
  17. package/src/db/client.d.ts.map +1 -0
  18. package/src/db/client.js +24 -0
  19. package/src/db/client.js.map +1 -0
  20. package/src/db/migrate-runner.d.ts +31 -0
  21. package/src/db/migrate-runner.d.ts.map +1 -0
  22. package/src/db/migrate-runner.js +35 -0
  23. package/src/db/migrate-runner.js.map +1 -0
  24. package/src/db/migrate.d.ts +9 -0
  25. package/src/db/migrate.d.ts.map +1 -0
  26. package/src/db/migrate.js +13 -0
  27. package/src/db/migrate.js.map +1 -0
  28. package/src/db/schema.d.ts +997 -0
  29. package/src/db/schema.d.ts.map +1 -0
  30. package/src/db/schema.js +323 -0
  31. package/src/db/schema.js.map +1 -0
  32. package/src/index.d.ts +21 -0
  33. package/src/index.d.ts.map +1 -0
  34. package/src/index.js +23 -0
  35. package/src/index.js.map +1 -0
  36. package/src/seed/components.d.ts +23 -0
  37. package/src/seed/components.d.ts.map +1 -0
  38. package/src/seed/components.js +399 -0
  39. package/src/seed/components.js.map +1 -0
  40. package/src/seed/index.d.ts +30 -0
  41. package/src/seed/index.d.ts.map +1 -0
  42. package/src/seed/index.js +95 -0
  43. package/src/seed/index.js.map +1 -0
  44. package/src/seed/prompt-types.d.ts +17 -0
  45. package/src/seed/prompt-types.d.ts.map +1 -0
  46. package/src/seed/prompt-types.js +107 -0
  47. package/src/seed/prompt-types.js.map +1 -0
  48. package/src/store/agent-store.d.ts +113 -0
  49. package/src/store/agent-store.d.ts.map +1 -0
  50. package/src/store/agent-store.js +211 -0
  51. package/src/store/agent-store.js.map +1 -0
  52. package/src/store/component-store.d.ts +87 -0
  53. package/src/store/component-store.d.ts.map +1 -0
  54. package/src/store/component-store.js +305 -0
  55. package/src/store/component-store.js.map +1 -0
  56. package/src/store/composed-prompt-store.d.ts +72 -0
  57. package/src/store/composed-prompt-store.d.ts.map +1 -0
  58. package/src/store/composed-prompt-store.js +147 -0
  59. package/src/store/composed-prompt-store.js.map +1 -0
  60. package/src/store/composition-store.d.ts +117 -0
  61. package/src/store/composition-store.d.ts.map +1 -0
  62. package/src/store/composition-store.js +270 -0
  63. package/src/store/composition-store.js.map +1 -0
  64. package/src/store/usecase-store.d.ts +104 -0
  65. package/src/store/usecase-store.d.ts.map +1 -0
  66. package/src/store/usecase-store.js +158 -0
  67. package/src/store/usecase-store.js.map +1 -0
@@ -0,0 +1,55 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "6",
8
+ "when": 1782193532682,
9
+ "tag": "0000_third_nitro",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "6",
15
+ "when": 1782194438176,
16
+ "tag": "0001_agents_and_taxonomy",
17
+ "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "6",
22
+ "when": 1782194854246,
23
+ "tag": "0002_agent_components_junction",
24
+ "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "6",
29
+ "when": 1782196800000,
30
+ "tag": "0003_usecase_context_rules",
31
+ "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "6",
36
+ "when": 1782195766328,
37
+ "tag": "0004_composed_prompts",
38
+ "breakpoints": true
39
+ },
40
+ {
41
+ "idx": 5,
42
+ "version": "6",
43
+ "when": 1782235784302,
44
+ "tag": "0005_warm_norman_osborn",
45
+ "breakpoints": true
46
+ },
47
+ {
48
+ "idx": 6,
49
+ "version": "6",
50
+ "when": 1782239097742,
51
+ "tag": "0006_component_head_version_split",
52
+ "breakpoints": true
53
+ }
54
+ ]
55
+ }
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@adhd/agent-store-prompts",
3
+ "version": "2.1.0",
4
+ "description": "Prompt component registry for agent composition: stores prompt types, components, agent compositions, and context rules",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "files": [
10
+ "src",
11
+ "drizzle"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./src/index.d.ts",
16
+ "default": "./src/index.js"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "build": "nx build agent-registry",
21
+ "typecheck": "tsc -p tsconfig.lib.json --noEmit",
22
+ "db:generate": "drizzle-kit generate",
23
+ "db:migrate": "drizzle-kit migrate"
24
+ },
25
+ "dependencies": {
26
+ "better-sqlite3": "12.10.0",
27
+ "drizzle-orm": "0.45.2"
28
+ },
29
+ "devDependencies": {
30
+ "@types/better-sqlite3": "^7.6.13",
31
+ "@vitest/coverage-v8": "^1.0.4",
32
+ "drizzle-kit": "^0.31.10",
33
+ "tslib": "^2.6.0",
34
+ "typescript": "^5.5.0",
35
+ "vite": "~5.0.13",
36
+ "vite-plugin-dts": "~3.8.3",
37
+ "vitest": "^1.6.0"
38
+ },
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/PseudoSky/adhd.git",
43
+ "directory": "packages/agent/agent-store-prompts"
44
+ },
45
+ "homepage": "https://github.com/PseudoSky/adhd/tree/main/packages/agent/agent-store-prompts#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/PseudoSky/adhd/issues"
48
+ },
49
+ "module": "./src/index.js",
50
+ "main": "./src/index.js"
51
+ }
@@ -0,0 +1,7 @@
1
+ import Database from 'better-sqlite3';
2
+ import * as schema from './schema.js';
3
+ export declare const sqlite: Database.Database;
4
+ export declare const db: import("drizzle-orm/better-sqlite3").BetterSQLite3Database<typeof schema> & {
5
+ $client: Database.Database;
6
+ };
7
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/db/client.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAqBtC,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,QAAqC,CAAC;AAKpE,eAAO,MAAM,EAAE;;CAA8B,CAAC"}
@@ -0,0 +1,24 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import Database from 'better-sqlite3';
4
+ import { drizzle } from 'drizzle-orm/better-sqlite3';
5
+ import * as schema from './schema.js';
6
+ // Decision 1 (decisions.md): one shared SQLite file for all registry-family packages.
7
+ // The path is shared across @adhd/agent-registry, @adhd/agent-tool-registry,
8
+ // @adhd/agent-provider, and @adhd/agent-policy — each opens its own Drizzle
9
+ // instance against the same file. No ATTACH DATABASE; no cross-package SQLite FKs.
10
+ const databasePath = process.env['REGISTRY_DATABASE_PATH'] ||
11
+ process.env['DATABASE_PATH'] ||
12
+ './data/registry.db';
13
+ const resolvedPath = path.resolve(databasePath);
14
+ const directory = path.dirname(resolvedPath);
15
+ if (!fs.existsSync(directory)) {
16
+ fs.mkdirSync(directory, {
17
+ recursive: true,
18
+ });
19
+ }
20
+ export const sqlite = new Database(resolvedPath);
21
+ sqlite.pragma('journal_mode = WAL');
22
+ sqlite.pragma('foreign_keys = ON');
23
+ export const db = drizzle(sqlite, { schema });
24
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/db/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,sFAAsF;AACtF,6EAA6E;AAC7E,4EAA4E;AAC5E,mFAAmF;AACnF,MAAM,YAAY,GAChB,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC5B,oBAAoB,CAAC;AAEvB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAEhD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAE7C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;IAC9B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE;QACtB,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAsB,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
2
+ /**
3
+ * Folder holding the drizzle-kit generated migrations (../../drizzle relative
4
+ * to this compiled module). Kept here — with no `client.js` import — so test
5
+ * harnesses can reuse the FK-safe runner without dragging in the production
6
+ * singleton connection (which opens a DB file at import time).
7
+ */
8
+ export declare const MIGRATIONS_FOLDER: string;
9
+ /**
10
+ * Minimal structural type for the bits of a better-sqlite3 connection we need.
11
+ * Avoids importing the better-sqlite3 type just to call `pragma`.
12
+ */
13
+ interface PragmaConn {
14
+ pragma(source: string, options?: {
15
+ simple: boolean;
16
+ }): unknown;
17
+ }
18
+ /**
19
+ * Run Drizzle migrations against an explicit connection with foreign-key
20
+ * enforcement disabled for the duration of the run.
21
+ *
22
+ * WHY: SQLite ignores `PRAGMA foreign_keys` inside a transaction, and drizzle's
23
+ * migrator wraps each migration file in one. Table-recreate migrations (ALTER
24
+ * TABLE via CREATE-INSERT-DROP-RENAME) fire ON DELETE CASCADE when FK enforcement
25
+ * is ON, wiping child rows. Disabling on the connection *before* migrate() —
26
+ * while no transaction is open — is the only way to make it hold for the whole
27
+ * run; we restore the prior setting afterwards.
28
+ */
29
+ export declare function runMigrationsOn(conn: PragmaConn, drizzleDb: Parameters<typeof migrate>[0], migrationsFolder?: string): void;
30
+ export {};
31
+ //# sourceMappingURL=migrate-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-runner.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/db/migrate-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QACnB,CAAC;AAEZ;;;GAGG;AACH,UAAU,UAAU;IAClB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC;CAChE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,EACxC,gBAAgB,GAAE,MAA0B,GAC3C,IAAI,CAcN"}
@@ -0,0 +1,35 @@
1
+ import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
2
+ /**
3
+ * Folder holding the drizzle-kit generated migrations (../../drizzle relative
4
+ * to this compiled module). Kept here — with no `client.js` import — so test
5
+ * harnesses can reuse the FK-safe runner without dragging in the production
6
+ * singleton connection (which opens a DB file at import time).
7
+ */
8
+ export const MIGRATIONS_FOLDER = new URL('../../drizzle', import.meta.url)
9
+ .pathname;
10
+ /**
11
+ * Run Drizzle migrations against an explicit connection with foreign-key
12
+ * enforcement disabled for the duration of the run.
13
+ *
14
+ * WHY: SQLite ignores `PRAGMA foreign_keys` inside a transaction, and drizzle's
15
+ * migrator wraps each migration file in one. Table-recreate migrations (ALTER
16
+ * TABLE via CREATE-INSERT-DROP-RENAME) fire ON DELETE CASCADE when FK enforcement
17
+ * is ON, wiping child rows. Disabling on the connection *before* migrate() —
18
+ * while no transaction is open — is the only way to make it hold for the whole
19
+ * run; we restore the prior setting afterwards.
20
+ */
21
+ export function runMigrationsOn(conn, drizzleDb, migrationsFolder = MIGRATIONS_FOLDER) {
22
+ const fkWasOn = conn.pragma('foreign_keys', { simple: true }) === 1;
23
+ if (fkWasOn) {
24
+ conn.pragma('foreign_keys = OFF');
25
+ }
26
+ try {
27
+ migrate(drizzleDb, { migrationsFolder });
28
+ }
29
+ finally {
30
+ if (fkWasOn) {
31
+ conn.pragma('foreign_keys = ON');
32
+ }
33
+ }
34
+ }
35
+ //# sourceMappingURL=migrate-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-runner.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/db/migrate-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;KACvE,QAAQ,CAAC;AAUZ;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAgB,EAChB,SAAwC,EACxC,mBAA2B,iBAAiB;IAE5C,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAEpE,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC;QACH,OAAO,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC3C,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Runs pending Drizzle migrations synchronously before the registry is used.
3
+ * Migrations are read from the ./drizzle folder (generated by drizzle-kit).
4
+ *
5
+ * Delegates to the FK-safe {@link runMigrationsOn} runner (see that module for
6
+ * why foreign-key enforcement must be toggled around the migration run).
7
+ */
8
+ export declare function runMigrations(): void;
9
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/db/migrate.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
@@ -0,0 +1,13 @@
1
+ import { db, sqlite } from './client.js';
2
+ import { runMigrationsOn } from './migrate-runner.js';
3
+ /**
4
+ * Runs pending Drizzle migrations synchronously before the registry is used.
5
+ * Migrations are read from the ./drizzle folder (generated by drizzle-kit).
6
+ *
7
+ * Delegates to the FK-safe {@link runMigrationsOn} runner (see that module for
8
+ * why foreign-key enforcement must be toggled around the migration run).
9
+ */
10
+ export function runMigrations() {
11
+ runMigrationsOn(sqlite, db);
12
+ }
13
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/db/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC"}