@shardworks/nexus-core 0.1.99 → 0.1.101

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 (166) hide show
  1. package/README.md +95 -166
  2. package/dist/guild-config.d.ts +14 -52
  3. package/dist/guild-config.d.ts.map +1 -1
  4. package/dist/guild-config.js +7 -10
  5. package/dist/guild-config.js.map +1 -1
  6. package/dist/guild.d.ts +83 -0
  7. package/dist/guild.d.ts.map +1 -0
  8. package/dist/guild.js +45 -0
  9. package/dist/guild.js.map +1 -0
  10. package/dist/id.d.ts +14 -0
  11. package/dist/id.d.ts.map +1 -0
  12. package/dist/id.js +19 -0
  13. package/dist/id.js.map +1 -0
  14. package/dist/index.d.ts +6 -30
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +7 -32
  17. package/dist/index.js.map +1 -1
  18. package/dist/nexus-home.d.ts +0 -4
  19. package/dist/nexus-home.d.ts.map +1 -1
  20. package/dist/nexus-home.js +1 -9
  21. package/dist/nexus-home.js.map +1 -1
  22. package/dist/plugin.d.ts +115 -0
  23. package/dist/plugin.d.ts.map +1 -0
  24. package/dist/plugin.js +39 -0
  25. package/dist/plugin.js.map +1 -0
  26. package/dist/resolve-package.d.ts +58 -0
  27. package/dist/resolve-package.d.ts.map +1 -0
  28. package/dist/resolve-package.js +123 -0
  29. package/dist/resolve-package.js.map +1 -0
  30. package/package.json +5 -14
  31. package/dist/book.d.ts +0 -110
  32. package/dist/book.d.ts.map +0 -1
  33. package/dist/book.js +0 -16
  34. package/dist/book.js.map +0 -1
  35. package/dist/legacy/1/anima.d.ts +0 -79
  36. package/dist/legacy/1/anima.d.ts.map +0 -1
  37. package/dist/legacy/1/anima.js +0 -285
  38. package/dist/legacy/1/anima.js.map +0 -1
  39. package/dist/legacy/1/audit.d.ts +0 -23
  40. package/dist/legacy/1/audit.d.ts.map +0 -1
  41. package/dist/legacy/1/audit.js +0 -61
  42. package/dist/legacy/1/audit.js.map +0 -1
  43. package/dist/legacy/1/bundle.d.ts +0 -111
  44. package/dist/legacy/1/bundle.d.ts.map +0 -1
  45. package/dist/legacy/1/bundle.js +0 -452
  46. package/dist/legacy/1/bundle.js.map +0 -1
  47. package/dist/legacy/1/clock-daemon.d.ts +0 -2
  48. package/dist/legacy/1/clock-daemon.d.ts.map +0 -1
  49. package/dist/legacy/1/clock-daemon.js +0 -72
  50. package/dist/legacy/1/clock-daemon.js.map +0 -1
  51. package/dist/legacy/1/clockworks.d.ts +0 -98
  52. package/dist/legacy/1/clockworks.d.ts.map +0 -1
  53. package/dist/legacy/1/clockworks.js +0 -359
  54. package/dist/legacy/1/clockworks.js.map +0 -1
  55. package/dist/legacy/1/conversation.d.ts +0 -165
  56. package/dist/legacy/1/conversation.d.ts.map +0 -1
  57. package/dist/legacy/1/conversation.js +0 -457
  58. package/dist/legacy/1/conversation.js.map +0 -1
  59. package/dist/legacy/1/engine.d.ts +0 -90
  60. package/dist/legacy/1/engine.d.ts.map +0 -1
  61. package/dist/legacy/1/engine.js +0 -89
  62. package/dist/legacy/1/engine.js.map +0 -1
  63. package/dist/legacy/1/events.d.ts +0 -88
  64. package/dist/legacy/1/events.d.ts.map +0 -1
  65. package/dist/legacy/1/events.js +0 -239
  66. package/dist/legacy/1/events.js.map +0 -1
  67. package/dist/legacy/1/guild-config.d.ts +0 -74
  68. package/dist/legacy/1/guild-config.d.ts.map +0 -1
  69. package/dist/legacy/1/guild-config.js +0 -51
  70. package/dist/legacy/1/guild-config.js.map +0 -1
  71. package/dist/legacy/1/id.d.ts +0 -8
  72. package/dist/legacy/1/id.d.ts.map +0 -1
  73. package/dist/legacy/1/id.js +0 -27
  74. package/dist/legacy/1/id.js.map +0 -1
  75. package/dist/legacy/1/index.d.ts +0 -28
  76. package/dist/legacy/1/index.d.ts.map +0 -1
  77. package/dist/legacy/1/index.js +0 -32
  78. package/dist/legacy/1/index.js.map +0 -1
  79. package/dist/legacy/1/init-guild.d.ts +0 -24
  80. package/dist/legacy/1/init-guild.d.ts.map +0 -1
  81. package/dist/legacy/1/init-guild.js +0 -230
  82. package/dist/legacy/1/init-guild.js.map +0 -1
  83. package/dist/legacy/1/install-tool.d.ts +0 -73
  84. package/dist/legacy/1/install-tool.d.ts.map +0 -1
  85. package/dist/legacy/1/install-tool.js +0 -436
  86. package/dist/legacy/1/install-tool.js.map +0 -1
  87. package/dist/legacy/1/instantiate.d.ts +0 -33
  88. package/dist/legacy/1/instantiate.d.ts.map +0 -1
  89. package/dist/legacy/1/instantiate.js +0 -137
  90. package/dist/legacy/1/instantiate.js.map +0 -1
  91. package/dist/legacy/1/manifest.d.ts +0 -132
  92. package/dist/legacy/1/manifest.d.ts.map +0 -1
  93. package/dist/legacy/1/manifest.js +0 -321
  94. package/dist/legacy/1/manifest.js.map +0 -1
  95. package/dist/legacy/1/migrate.d.ts +0 -84
  96. package/dist/legacy/1/migrate.d.ts.map +0 -1
  97. package/dist/legacy/1/migrate.js +0 -228
  98. package/dist/legacy/1/migrate.js.map +0 -1
  99. package/dist/legacy/1/nexus-home.d.ts +0 -11
  100. package/dist/legacy/1/nexus-home.d.ts.map +0 -1
  101. package/dist/legacy/1/nexus-home.js +0 -16
  102. package/dist/legacy/1/nexus-home.js.map +0 -1
  103. package/dist/legacy/1/plugin-descriptor.d.ts +0 -3
  104. package/dist/legacy/1/plugin-descriptor.d.ts.map +0 -1
  105. package/dist/legacy/1/plugin-descriptor.js +0 -2
  106. package/dist/legacy/1/plugin-descriptor.js.map +0 -1
  107. package/dist/legacy/1/preconditions.d.ts +0 -100
  108. package/dist/legacy/1/preconditions.d.ts.map +0 -1
  109. package/dist/legacy/1/preconditions.js +0 -189
  110. package/dist/legacy/1/preconditions.js.map +0 -1
  111. package/dist/legacy/1/rehydrate.d.ts +0 -22
  112. package/dist/legacy/1/rehydrate.d.ts.map +0 -1
  113. package/dist/legacy/1/rehydrate.js +0 -109
  114. package/dist/legacy/1/rehydrate.js.map +0 -1
  115. package/dist/legacy/1/remove-tool.d.ts +0 -19
  116. package/dist/legacy/1/remove-tool.d.ts.map +0 -1
  117. package/dist/legacy/1/remove-tool.js +0 -105
  118. package/dist/legacy/1/remove-tool.js.map +0 -1
  119. package/dist/legacy/1/session.d.ts +0 -343
  120. package/dist/legacy/1/session.d.ts.map +0 -1
  121. package/dist/legacy/1/session.js +0 -499
  122. package/dist/legacy/1/session.js.map +0 -1
  123. package/dist/legacy/1/tool-registry.d.ts +0 -12
  124. package/dist/legacy/1/tool-registry.d.ts.map +0 -1
  125. package/dist/legacy/1/tool-registry.js +0 -28
  126. package/dist/legacy/1/tool-registry.js.map +0 -1
  127. package/dist/legacy/1/tool.d.ts +0 -10
  128. package/dist/legacy/1/tool.d.ts.map +0 -1
  129. package/dist/legacy/1/tool.js +0 -2
  130. package/dist/legacy/1/tool.js.map +0 -1
  131. package/dist/legacy/1/upgrade.d.ts +0 -129
  132. package/dist/legacy/1/upgrade.d.ts.map +0 -1
  133. package/dist/legacy/1/upgrade.js +0 -355
  134. package/dist/legacy/1/upgrade.js.map +0 -1
  135. package/dist/legacy/1/workshop.d.ts +0 -95
  136. package/dist/legacy/1/workshop.d.ts.map +0 -1
  137. package/dist/legacy/1/workshop.js +0 -229
  138. package/dist/legacy/1/workshop.js.map +0 -1
  139. package/dist/legacy/1/worktree.d.ts +0 -67
  140. package/dist/legacy/1/worktree.d.ts.map +0 -1
  141. package/dist/legacy/1/worktree.js +0 -117
  142. package/dist/legacy/1/worktree.js.map +0 -1
  143. package/dist/legacy/1/writ.d.ts +0 -130
  144. package/dist/legacy/1/writ.d.ts.map +0 -1
  145. package/dist/legacy/1/writ.js +0 -599
  146. package/dist/legacy/1/writ.js.map +0 -1
  147. package/dist/rig-context.d.ts +0 -47
  148. package/dist/rig-context.d.ts.map +0 -1
  149. package/dist/rig-context.js +0 -11
  150. package/dist/rig-context.js.map +0 -1
  151. package/dist/rig-descriptor.d.ts +0 -39
  152. package/dist/rig-descriptor.d.ts.map +0 -1
  153. package/dist/rig-descriptor.js +0 -12
  154. package/dist/rig-descriptor.js.map +0 -1
  155. package/dist/rig.d.ts +0 -70
  156. package/dist/rig.d.ts.map +0 -1
  157. package/dist/rig.js +0 -14
  158. package/dist/rig.js.map +0 -1
  159. package/dist/tool.d.ts +0 -136
  160. package/dist/tool.d.ts.map +0 -1
  161. package/dist/tool.js +0 -135
  162. package/dist/tool.js.map +0 -1
  163. package/migrations/001-schema.sql +0 -177
  164. package/migrations/002-writs.sql +0 -44
  165. package/migrations/003-conversations.sql +0 -43
  166. package/migrations/004-remove-commissions.sql +0 -24
@@ -1,129 +0,0 @@
1
- /**
2
- * Upgrade — plan and apply framework upgrades to an existing guild.
3
- *
4
- * Compares the guild's current state against a bundle (typically the
5
- * guild-starter-kit at a newer version) and produces a plan describing:
6
- *
7
- * - New tools and engines to register (with role assignments)
8
- * - Updated curricula and temperaments
9
- * - Stale anima compositions (using outdated training content)
10
- *
11
- * Database migrations are handled separately by nexus-core and applied
12
- * automatically on database open (see `ensureBooks()` in migrate.ts).
13
- *
14
- * The plan can be inspected (dry-run) or applied. Content artifacts
15
- * are overwritten with the newer version. Stale animas are reported
16
- * but not automatically recomposed — the operator decides.
17
- */
18
- /** A migration that the bundle wants to deliver but the guild doesn't have. */
19
- export interface MigrationPlanEntry {
20
- /** Original filename in the bundle (e.g. "002-clockworks.sql"). */
21
- bundleFilename: string;
22
- /** The sequence number it will get in the guild. */
23
- guildSequence: number;
24
- /** The filename it will have in the guild (e.g. "005-clockworks.sql"). */
25
- guildFilename: string;
26
- }
27
- /** A content artifact (curriculum or temperament) that has a newer version available. */
28
- export interface ContentUpdateEntry {
29
- /** Category: 'curricula' or 'temperaments'. */
30
- category: 'curricula' | 'temperaments';
31
- /** Name of the content artifact. */
32
- name: string;
33
- /** Currently installed version (from guild.json entry or disk descriptor). */
34
- installedVersion: string;
35
- /** Version in the bundle. */
36
- bundleVersion: string;
37
- /** Path in the bundle to the content directory. */
38
- bundlePath: string;
39
- }
40
- /** A tool or engine that the bundle declares but the guild doesn't have. */
41
- export interface ToolPlanEntry {
42
- /** Category: 'tools' or 'engines'. */
43
- category: 'tools' | 'engines';
44
- /** Artifact name in the guild. */
45
- name: string;
46
- /** npm package that provides this tool. */
47
- package: string;
48
- /** Roles this tool should be assigned to (from the bundle manifest). */
49
- roles: string[];
50
- }
51
- /** An anima whose composition references an outdated curriculum or temperament. */
52
- export interface StaleAnimaEntry {
53
- /** Anima ID. */
54
- id: string;
55
- /** Anima name. */
56
- name: string;
57
- /** Roles held by the anima. */
58
- roles: string[];
59
- /** Curriculum staleness (null if current or no curriculum). */
60
- curriculum: {
61
- composedVersion: string;
62
- currentVersion: string;
63
- } | null;
64
- /** Temperament staleness (null if current or no temperament). */
65
- temperament: {
66
- composedVersion: string;
67
- currentVersion: string;
68
- } | null;
69
- }
70
- /** The full upgrade plan. */
71
- export interface UpgradePlan {
72
- /** Bundle source identifier (e.g. "@shardworks/guild-starter-kit@0.1.55"). */
73
- bundleSource: string;
74
- /** New migrations to install and apply. */
75
- migrations: MigrationPlanEntry[];
76
- /** Content artifacts with newer versions available. */
77
- contentUpdates: ContentUpdateEntry[];
78
- /** Tools and engines the bundle declares but the guild doesn't have. */
79
- newTools: ToolPlanEntry[];
80
- /** Animas running on outdated compositions. */
81
- staleAnimas: StaleAnimaEntry[];
82
- /** Whether there is anything to do. */
83
- isEmpty: boolean;
84
- }
85
- /** Options for applying an upgrade plan. */
86
- export interface ApplyUpgradeOptions {
87
- /** If true, retire stale animas and recreate them with fresh compositions. */
88
- recompose?: boolean;
89
- }
90
- /** Result of applying an upgrade plan. */
91
- export interface UpgradeResult {
92
- /** Migrations that were installed and applied. */
93
- migrationsApplied: string[];
94
- /** Content artifacts that were updated. */
95
- contentUpdated: string[];
96
- /** Tools and engines that were registered. */
97
- toolsRegistered: string[];
98
- /** Number of stale animas (reported, not changed). */
99
- staleAnimaCount: number;
100
- /** Animas that were recomposed (retired + recreated). */
101
- recomposedAnimas: string[];
102
- }
103
- /**
104
- * Plan an upgrade by diffing the guild's current state against a bundle.
105
- *
106
- * This is a read-only operation — it inspects the guild and bundle but
107
- * makes no changes. The returned plan describes everything that would
108
- * happen if the upgrade were applied.
109
- *
110
- * @param home - Absolute path to the guild root.
111
- * @param bundleDir - Absolute path to the bundle directory.
112
- * @param bundleSource - Provenance string (e.g. "@shardworks/guild-starter-kit@0.1.55").
113
- */
114
- export declare function planUpgrade(home: string, bundleDir: string, bundleSource?: string): UpgradePlan;
115
- /**
116
- * Apply an upgrade plan to the guild.
117
- *
118
- * Installs new migrations, updates content artifacts, and bumps the
119
- * nexus version in guild.json. Optionally recomposes stale animas
120
- * (retires each one and recreates with the same name, roles, curriculum,
121
- * and temperament — picking up the latest training content).
122
- *
123
- * @param home - Absolute path to the guild root.
124
- * @param bundleDir - Absolute path to the bundle directory.
125
- * @param plan - The upgrade plan to apply (from planUpgrade).
126
- * @param opts - Options (e.g. recompose).
127
- */
128
- export declare function applyUpgrade(home: string, bundleDir: string, plan: UpgradePlan, opts?: ApplyUpgradeOptions): UpgradeResult;
129
- //# sourceMappingURL=upgrade.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../../src/legacy/1/upgrade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAcH,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,yFAAyF;AACzF,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,QAAQ,EAAE,WAAW,GAAG,cAAc,CAAC;IACvC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,gBAAgB,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,mDAAmD;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CAAC;IAC5B,2CAA2C;IAC3C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,8CAA8C;IAC9C,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,sDAAsD;IACtD,eAAe,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AA0CD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACpB,WAAW,CA8Cb;AAuKD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,WAAW,EACjB,IAAI,GAAE,mBAAwB,GAC7B,aAAa,CAgHf"}
@@ -1,355 +0,0 @@
1
- /**
2
- * Upgrade — plan and apply framework upgrades to an existing guild.
3
- *
4
- * Compares the guild's current state against a bundle (typically the
5
- * guild-starter-kit at a newer version) and produces a plan describing:
6
- *
7
- * - New tools and engines to register (with role assignments)
8
- * - Updated curricula and temperaments
9
- * - Stale anima compositions (using outdated training content)
10
- *
11
- * Database migrations are handled separately by nexus-core and applied
12
- * automatically on database open (see `ensureBooks()` in migrate.ts).
13
- *
14
- * The plan can be inspected (dry-run) or applied. Content artifacts
15
- * are overwritten with the newer version. Stale animas are reported
16
- * but not automatically recomposed — the operator decides.
17
- */
18
- import fs from 'node:fs';
19
- import path from 'node:path';
20
- import Database from 'better-sqlite3';
21
- import { booksPath } from "./nexus-home.js";
22
- import { readGuildConfig, writeGuildConfig } from "./guild-config.js";
23
- import { readBundleManifest } from "./bundle.js";
24
- import { listAnimas, checkAllAnimaStaleness } from "./anima.js";
25
- import { removeAnima } from "./anima.js";
26
- import { instantiate } from "./instantiate.js";
27
- // ── Helpers ─────────────────────────────────────────────────────────────
28
- function readJson(filePath) {
29
- return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
30
- }
31
- /** Recursively copy a directory, skipping node_modules and .git. */
32
- const SKIP_DIRS = new Set(['node_modules', '.git']);
33
- function copyDir(src, dest) {
34
- fs.mkdirSync(dest, { recursive: true });
35
- for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
36
- const srcPath = path.join(src, entry.name);
37
- const destPath = path.join(dest, entry.name);
38
- if (entry.isDirectory()) {
39
- if (!SKIP_DIRS.has(entry.name)) {
40
- copyDir(srcPath, destPath);
41
- }
42
- }
43
- else {
44
- fs.copyFileSync(srcPath, destPath);
45
- }
46
- }
47
- }
48
- /**
49
- * Read a content descriptor (nexus-curriculum.json or nexus-temperament.json)
50
- * and return its version string.
51
- */
52
- function readContentVersion(dir, category) {
53
- const descriptorFile = category === 'curricula'
54
- ? 'nexus-curriculum.json'
55
- : 'nexus-temperament.json';
56
- const descriptorPath = path.join(dir, descriptorFile);
57
- if (!fs.existsSync(descriptorPath))
58
- return 'unknown';
59
- const descriptor = readJson(descriptorPath);
60
- return descriptor.version || 'unknown';
61
- }
62
- // ── Plan ────────────────────────────────────────────────────────────────
63
- /**
64
- * Plan an upgrade by diffing the guild's current state against a bundle.
65
- *
66
- * This is a read-only operation — it inspects the guild and bundle but
67
- * makes no changes. The returned plan describes everything that would
68
- * happen if the upgrade were applied.
69
- *
70
- * @param home - Absolute path to the guild root.
71
- * @param bundleDir - Absolute path to the bundle directory.
72
- * @param bundleSource - Provenance string (e.g. "@shardworks/guild-starter-kit@0.1.55").
73
- */
74
- export function planUpgrade(home, bundleDir, bundleSource) {
75
- // Auto-detect bundle provenance if not provided
76
- if (!bundleSource) {
77
- const bundlePkgPath = path.join(bundleDir, 'package.json');
78
- if (fs.existsSync(bundlePkgPath)) {
79
- const pkg = readJson(bundlePkgPath);
80
- const name = pkg.name;
81
- const version = pkg.version;
82
- if (name && version)
83
- bundleSource = `${name}@${version}`;
84
- }
85
- }
86
- bundleSource = bundleSource || path.basename(bundleDir);
87
- const manifest = readBundleManifest(bundleDir);
88
- const plan = {
89
- bundleSource,
90
- migrations: [],
91
- contentUpdates: [],
92
- newTools: [],
93
- staleAnimas: [],
94
- isEmpty: true,
95
- };
96
- // ── Tool/engine diff ───────────────────────────────────────────────
97
- planNewTools(home, manifest, 'tools', plan);
98
- planNewTools(home, manifest, 'engines', plan);
99
- // ── Content diff ────────────────────────────────────────────────────
100
- planContentUpdates(home, bundleDir, manifest, 'curricula', plan);
101
- planContentUpdates(home, bundleDir, manifest, 'temperaments', plan);
102
- // ── Stale anima detection ───────────────────────────────────────────
103
- // This detects staleness based on what's *currently* on disk, plus
104
- // any content updates the plan would apply. So if the plan updates
105
- // curriculum v1.0 → v1.1, animas on v1.0 will show as stale.
106
- detectStaleAnimas(home, plan);
107
- plan.isEmpty = plan.newTools.length === 0
108
- && plan.contentUpdates.length === 0
109
- && plan.staleAnimas.length === 0;
110
- return plan;
111
- }
112
- /**
113
- * Diff bundle tools/engines against what the guild already has registered.
114
- *
115
- * Any tool declared in the bundle but missing from guild.json is planned
116
- * for installation, along with its role assignments.
117
- */
118
- function planNewTools(home, manifest, category, plan) {
119
- const entries = manifest[category];
120
- if (!entries)
121
- return;
122
- const config = readGuildConfig(home);
123
- const registered = config[category];
124
- for (const entry of entries) {
125
- const name = entry.name || entry.package;
126
- if (registered[name])
127
- continue; // Already registered
128
- plan.newTools.push({
129
- category,
130
- name,
131
- package: entry.package,
132
- roles: entry.roles ?? [],
133
- });
134
- }
135
- }
136
- /**
137
- * Diff bundle content (curricula or temperaments) against guild versions.
138
- */
139
- function planContentUpdates(home, bundleDir, manifest, category, plan) {
140
- const entries = manifest[category];
141
- if (!entries)
142
- return;
143
- for (const entry of entries) {
144
- // Only handle inline content (path-based). Package content is handled
145
- // by npm update and doesn't need special upgrade logic.
146
- if (!entry.path)
147
- continue;
148
- const contentDir = path.resolve(bundleDir, entry.path);
149
- if (!fs.existsSync(contentDir))
150
- continue;
151
- const name = entry.name || path.basename(contentDir);
152
- const bundleVersion = readContentVersion(contentDir, category);
153
- // Read installed version from disk
154
- const parentDir = category === 'curricula' ? 'training/curricula' : 'training/temperaments';
155
- const installedDir = path.join(home, parentDir, name);
156
- const installedVersion = fs.existsSync(installedDir)
157
- ? readContentVersion(installedDir, category)
158
- : 'not installed';
159
- if (bundleVersion !== installedVersion) {
160
- plan.contentUpdates.push({
161
- category,
162
- name,
163
- installedVersion,
164
- bundleVersion,
165
- bundlePath: entry.path,
166
- });
167
- }
168
- }
169
- }
170
- /**
171
- * Detect animas whose compositions reference outdated training content.
172
- *
173
- * Uses the shared checkAllAnimaStaleness function, then enriches with
174
- * planned content update versions (so animas are flagged as stale even
175
- * if the content hasn't been written to disk yet).
176
- */
177
- function detectStaleAnimas(home, plan) {
178
- const dbPath = booksPath(home);
179
- if (!fs.existsSync(dbPath))
180
- return;
181
- // Check that the animas table exists
182
- const db = new Database(dbPath);
183
- try {
184
- const hasAnimas = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='animas'`).get();
185
- if (!hasAnimas)
186
- return;
187
- }
188
- finally {
189
- db.close();
190
- }
191
- // Get all active animas for enrichment
192
- const activeAnimas = listAnimas(home, { status: 'active' });
193
- // Use the shared staleness check for current on-disk state
194
- const currentStaleness = checkAllAnimaStaleness(home);
195
- // Also check against planned content updates (content not yet on disk)
196
- // Build a map of what versions will be current after upgrade
197
- const plannedVersions = new Map();
198
- for (const update of plan.contentUpdates) {
199
- plannedVersions.set(`${update.category}:${update.name}`, update.bundleVersion);
200
- }
201
- // For each active anima, check both current staleness and planned staleness
202
- const db2 = new Database(booksPath(home));
203
- db2.pragma('foreign_keys = ON');
204
- try {
205
- for (const anima of activeAnimas) {
206
- // Get composition data
207
- const comp = db2.prepare(`
208
- SELECT curriculum_name, curriculum_version,
209
- temperament_name, temperament_version
210
- FROM anima_compositions WHERE anima_id = ?
211
- `).get(anima.id);
212
- if (!comp)
213
- continue;
214
- // Start with current staleness
215
- const existing = currentStaleness.get(anima.id);
216
- let curriculum = existing?.curriculum ?? null;
217
- let temperament = existing?.temperament ?? null;
218
- // Check planned curriculum update
219
- if (!curriculum && comp.curriculum_name && comp.curriculum_version) {
220
- const plannedVersion = plannedVersions.get(`curricula:${comp.curriculum_name}`);
221
- if (plannedVersion && plannedVersion !== comp.curriculum_version) {
222
- curriculum = { composedVersion: comp.curriculum_version, currentVersion: plannedVersion };
223
- }
224
- }
225
- // Check planned temperament update
226
- if (!temperament && comp.temperament_name && comp.temperament_version) {
227
- const plannedVersion = plannedVersions.get(`temperaments:${comp.temperament_name}`);
228
- if (plannedVersion && plannedVersion !== comp.temperament_version) {
229
- temperament = { composedVersion: comp.temperament_version, currentVersion: plannedVersion };
230
- }
231
- }
232
- if (curriculum || temperament) {
233
- plan.staleAnimas.push({
234
- id: anima.id,
235
- name: anima.name,
236
- roles: anima.roles,
237
- curriculum,
238
- temperament,
239
- });
240
- }
241
- }
242
- }
243
- finally {
244
- db2.close();
245
- }
246
- }
247
- // ── Apply ───────────────────────────────────────────────────────────────
248
- /**
249
- * Apply an upgrade plan to the guild.
250
- *
251
- * Installs new migrations, updates content artifacts, and bumps the
252
- * nexus version in guild.json. Optionally recomposes stale animas
253
- * (retires each one and recreates with the same name, roles, curriculum,
254
- * and temperament — picking up the latest training content).
255
- *
256
- * @param home - Absolute path to the guild root.
257
- * @param bundleDir - Absolute path to the bundle directory.
258
- * @param plan - The upgrade plan to apply (from planUpgrade).
259
- * @param opts - Options (e.g. recompose).
260
- */
261
- export function applyUpgrade(home, bundleDir, plan, opts = {}) {
262
- const result = {
263
- migrationsApplied: [],
264
- contentUpdated: [],
265
- toolsRegistered: [],
266
- staleAnimaCount: plan.staleAnimas.length,
267
- recomposedAnimas: [],
268
- };
269
- // ── Update content artifacts ──────────────────────────────────────
270
- for (const update of plan.contentUpdates) {
271
- const parentDir = update.category === 'curricula'
272
- ? 'training/curricula'
273
- : 'training/temperaments';
274
- const targetDir = path.join(home, parentDir, update.name);
275
- const sourceDir = path.resolve(bundleDir, update.bundlePath);
276
- // Remove old content and copy new
277
- if (fs.existsSync(targetDir)) {
278
- fs.rmSync(targetDir, { recursive: true });
279
- }
280
- fs.mkdirSync(targetDir, { recursive: true });
281
- copyDir(sourceDir, targetDir);
282
- // Update guild.json entry
283
- const config = readGuildConfig(home);
284
- if (config[update.category][update.name]) {
285
- config[update.category][update.name].installedAt = new Date().toISOString();
286
- if (plan.bundleSource) {
287
- config[update.category][update.name].bundle = plan.bundleSource;
288
- }
289
- }
290
- writeGuildConfig(home, config);
291
- result.contentUpdated.push(`${update.category}/${update.name}`);
292
- }
293
- // ── Register new tools/engines ──────────────────────────────────────
294
- if (plan.newTools.length > 0) {
295
- const config = readGuildConfig(home);
296
- const now = new Date().toISOString();
297
- for (const tool of plan.newTools) {
298
- // Register in the guild's tool/engine catalog
299
- config[tool.category][tool.name] = {
300
- upstream: null,
301
- installedAt: now,
302
- package: tool.package.replace(/@[^@/]+$/, ''), // strip version from specifier
303
- ...(plan.bundleSource ? { bundle: plan.bundleSource } : {}),
304
- };
305
- // Add to each declared role's tool list
306
- for (const roleName of tool.roles) {
307
- const role = config.roles[roleName];
308
- if (role && !role.tools.includes(tool.name)) {
309
- role.tools.push(tool.name);
310
- }
311
- }
312
- result.toolsRegistered.push(`${tool.category}/${tool.name}`);
313
- }
314
- writeGuildConfig(home, config);
315
- }
316
- // ── Recompose stale animas ─────────────────────────────────────────
317
- if (opts.recompose && plan.staleAnimas.length > 0) {
318
- for (const staleAnima of plan.staleAnimas) {
319
- // Read the full detail before retiring (need curriculum/temperament names)
320
- const db = new Database(booksPath(home));
321
- db.pragma('foreign_keys = ON');
322
- let curriculumName;
323
- let temperamentName;
324
- try {
325
- const comp = db.prepare(`
326
- SELECT curriculum_name, temperament_name
327
- FROM anima_compositions WHERE anima_id = ?
328
- `).get(staleAnima.id);
329
- curriculumName = comp?.curriculum_name || undefined;
330
- temperamentName = comp?.temperament_name || undefined;
331
- }
332
- finally {
333
- db.close();
334
- }
335
- // Retire the old anima and rename it to free up the name.
336
- // The retired anima keeps a timestamped name for audit trail.
337
- removeAnima(home, staleAnima.id);
338
- const retiredName = `${staleAnima.name} (retired ${new Date().toISOString().slice(0, 19)})`;
339
- const renameDb = new Database(booksPath(home));
340
- renameDb.prepare(`UPDATE animas SET name = ? WHERE id = ?`).run(retiredName, staleAnima.id);
341
- renameDb.close();
342
- // Recreate with the same name, roles, curriculum, and temperament
343
- instantiate({
344
- home,
345
- name: staleAnima.name,
346
- roles: staleAnima.roles,
347
- curriculum: curriculumName,
348
- temperament: temperamentName,
349
- });
350
- result.recomposedAnimas.push(staleAnima.name);
351
- }
352
- }
353
- return result;
354
- }
355
- //# sourceMappingURL=upgrade.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../../src/legacy/1/upgrade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAuB,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA0F/C,2EAA2E;AAE3E,SAAS,QAAQ,CAAC,QAAgB;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,oEAAoE;AACpE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpD,SAA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CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;YAC5F,QAAQ,CAAC,KAAK,EAAE,CAAC;YAEjB,kEAAkE;YAClE,WAAW,CAAC;gBACV,IAAI;gBACJ,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,UAAU,EAAE,cAAc;gBAC1B,WAAW,EAAE,eAAe;aAC7B,CAAC,CAAC;YAEH,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,95 +0,0 @@
1
- export interface AddWorkshopOptions {
2
- /** Absolute path to the guild root. */
3
- home: string;
4
- /** Workshop name (used as the key in guild.json and the bare clone directory name). */
5
- name: string;
6
- /** Git remote URL to clone from. */
7
- remoteUrl: string;
8
- }
9
- export interface AddWorkshopResult {
10
- /** Workshop name. */
11
- name: string;
12
- /** Remote URL that was cloned. */
13
- remoteUrl: string;
14
- /** Path to the bare clone on disk. */
15
- barePath: string;
16
- }
17
- export interface RemoveWorkshopOptions {
18
- /** Absolute path to the guild root. */
19
- home: string;
20
- /** Workshop name to remove. */
21
- name: string;
22
- }
23
- export interface WorkshopInfo {
24
- /** Workshop name. */
25
- name: string;
26
- /** Remote URL from guild.json. */
27
- remoteUrl: string;
28
- /** When the workshop was added. */
29
- addedAt: string;
30
- /** Whether the bare clone exists on disk. */
31
- cloned: boolean;
32
- /** Number of active writ worktrees. */
33
- activeWorktrees: number;
34
- }
35
- export interface CreateWorkshopOptions {
36
- /** Absolute path to the guild root. */
37
- home: string;
38
- /** Repository name in org/name format. */
39
- repoName: string;
40
- /** Whether to create a private repo (default: true). */
41
- private?: boolean;
42
- }
43
- /**
44
- * Derive a workshop name from a remote URL or repo name.
45
- * "https://github.com/org/my-repo.git" → "my-repo"
46
- * "org/my-repo" → "my-repo"
47
- * "git@github.com:org/my-repo.git" → "my-repo"
48
- */
49
- export declare function deriveWorkshopName(input: string): string;
50
- /**
51
- * Add a workshop by cloning a remote repo as a bare clone and registering
52
- * it in guild.json.
53
- *
54
- * @throws If the workshop name already exists in guild.json.
55
- * @throws If the bare clone directory already exists on disk.
56
- * @throws If the git clone fails.
57
- */
58
- export declare function addWorkshop(opts: AddWorkshopOptions): AddWorkshopResult;
59
- /**
60
- * Remove a workshop — deletes the bare clone, any writ worktrees,
61
- * and the guild.json entry.
62
- *
63
- * @throws If the workshop doesn't exist in guild.json.
64
- */
65
- export declare function removeWorkshop(opts: RemoveWorkshopOptions): void;
66
- /**
67
- * List all workshops with status info.
68
- */
69
- export declare function listWorkshops(home: string): WorkshopInfo[];
70
- export interface WorkshopDetail extends WorkshopInfo {
71
- /** Absolute path to the bare clone on disk. */
72
- barePath: string;
73
- /** Default branch name, if bare clone exists. */
74
- defaultBranch: string | null;
75
- }
76
- /**
77
- * Show detailed info for a single workshop.
78
- */
79
- export declare function showWorkshop(home: string, name: string): WorkshopDetail | null;
80
- /**
81
- * Check whether `gh` is installed and authenticated.
82
- * Returns null if OK, or an error message if not.
83
- */
84
- export declare function checkGhAuth(): string | null;
85
- /**
86
- * Create a new GitHub repo and add it as a workshop.
87
- *
88
- * Precondition: `gh` must be installed and authenticated. Call checkGhAuth()
89
- * first to verify.
90
- *
91
- * @param opts.repoName - Repository name in "org/name" format.
92
- * @throws If gh auth check fails, repo creation fails, or add fails.
93
- */
94
- export declare function createWorkshop(opts: CreateWorkshopOptions): AddWorkshopResult;
95
- //# sourceMappingURL=workshop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workshop.d.ts","sourceRoot":"","sources":["../../../src/legacy/1/workshop.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,S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