@a-company/paradigm 3.9.0 → 3.11.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 (39) hide show
  1. package/dist/{accept-orchestration-DIGPJVUR.js → accept-orchestration-Z35I5AYN.js} +5 -5
  2. package/dist/{assessment-loader-T4GPBHLB.js → assessment-loader-C5EOUM47.js} +0 -1
  3. package/dist/{chunk-Y4XZWCHK.js → chunk-24AAVLME.js} +8 -8
  4. package/dist/{chunk-4N6AYEEA.js → chunk-3TWXFFZ3.js} +1 -1
  5. package/dist/{chunk-5S5CF3ER.js → chunk-4ZO3ZOPM.js} +19 -2141
  6. package/dist/{chunk-6RNYVBSG.js → chunk-CP6IZGUN.js} +4 -4
  7. package/dist/{chunk-M2XMTJHQ.js → chunk-DS5QY37M.js} +201 -287
  8. package/dist/chunk-F6EJKLF4.js +4971 -0
  9. package/dist/chunk-MW5DMGBB.js +255 -0
  10. package/dist/{chunk-KFHK6EBI.js → chunk-OSYMVGWX.js} +59 -3
  11. package/dist/{chunk-GY5KO3YZ.js → chunk-RDPXBMHK.js} +1 -1
  12. package/dist/{chunk-ADOBV4PH.js → chunk-UVI3OH3G.js} +6 -2127
  13. package/dist/{diff-J6C5IHPV.js → diff-PZAYCIAE.js} +5 -5
  14. package/dist/{dist-OLFOTUHS.js → dist-6SX5ZKKF.js} +2 -2
  15. package/dist/{dist-OMY7U6NR.js → dist-YB7T54QE.js} +1 -2
  16. package/dist/{doctor-TQYRF7KK.js → doctor-3YQ55536.js} +1 -1
  17. package/dist/drift-FH2UY64B.js +251 -0
  18. package/dist/{flow-7JUH6D4H.js → flow-MCKPJGRJ.js} +1 -1
  19. package/dist/{habits-ZJBAL4HD.js → habits-NC2TRMRV.js} +2 -2
  20. package/dist/{hooks-DLZEYHI3.js → hooks-JXYHVGIN.js} +1 -1
  21. package/dist/index.js +77 -51
  22. package/dist/mcp.js +5502 -9984
  23. package/dist/{orchestrate-FAV64G2R.js → orchestrate-BGRFBGBH.js} +5 -5
  24. package/dist/{plugin-update-checker-TWBWUSAG.js → plugin-update-checker-S3W4BUJO.js} +0 -1
  25. package/dist/portal-check-2HI4FFD6.js +42 -0
  26. package/dist/portal-compliance-KQCTAQTJ.js +18 -0
  27. package/dist/{providers-NQ67LO2Z.js → providers-IONB4YRJ.js} +1 -1
  28. package/dist/reindex-ZM6J53UP.js +11 -0
  29. package/dist/{sentinel-KDIGZWKT.js → sentinel-BGCISNIK.js} +1 -1
  30. package/dist/{server-NN7WDAZJ.js → server-3K3TTJH3.js} +1 -1
  31. package/dist/{shift-KJWSJLWN.js → shift-6I6N6RNK.js} +36 -8
  32. package/dist/{spawn-EO7B2UM3.js → spawn-WGFJ5RQZ.js} +5 -5
  33. package/dist/{task-loader-GUX4KS6N.js → task-loader-7M2FCBX6.js} +0 -1
  34. package/dist/{team-6CCNANKE.js → team-AFOKQ7YQ.js} +6 -6
  35. package/dist/{triage-B5W6GZLT.js → triage-MKKIWBSW.js} +2 -2
  36. package/dist/workspace-VBTW7OYL.js +271 -0
  37. package/package.json +2 -1
  38. package/dist/chunk-HPC3JAUP.js +0 -42
  39. /package/dist/{chunk-CCG6KYBT.js → chunk-5N5LR2KS.js} +0 -0
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  BackgroundOrchestrator
4
- } from "./chunk-Y4XZWCHK.js";
4
+ } from "./chunk-24AAVLME.js";
5
5
  import "./chunk-6QC3YGB6.js";
6
- import "./chunk-HPC3JAUP.js";
7
- import "./chunk-6RNYVBSG.js";
8
- import "./chunk-PBHIFAL4.js";
9
- import "./chunk-CCG6KYBT.js";
6
+ import "./chunk-CP6IZGUN.js";
10
7
  import "./chunk-PMXRGPRQ.js";
8
+ import "./chunk-PBHIFAL4.js";
9
+ import "./chunk-5N5LR2KS.js";
11
10
  import "./chunk-6P4IFIK2.js";
12
11
  import "./chunk-MRENOFTR.js";
13
12
  import "./chunk-IRKUEJVW.js";
13
+ import "./chunk-MW5DMGBB.js";
14
14
  import "./chunk-5JGJACDU.js";
15
15
  import "./chunk-MO4EEYFW.js";
16
16
 
@@ -20,7 +20,7 @@ import {
20
20
  loadAllSeedPatterns,
21
21
  loadParadigmPatterns,
22
22
  loadUniversalPatterns
23
- } from "./chunk-GY5KO3YZ.js";
23
+ } from "./chunk-RDPXBMHK.js";
24
24
  import {
25
25
  DEFAULT_AUTH_CONFIG,
26
26
  DEFAULT_RATE_LIMIT_CONFIG,
@@ -29,7 +29,7 @@ import {
29
29
  loadConfig,
30
30
  loadServerConfig,
31
31
  writeConfig
32
- } from "./chunk-ADOBV4PH.js";
32
+ } from "./chunk-UVI3OH3G.js";
33
33
  import "./chunk-MO4EEYFW.js";
34
34
  export {
35
35
  ContextEnricher,
@@ -26,8 +26,7 @@ import {
26
26
  loadServerConfig,
27
27
  loadUniversalPatterns,
28
28
  writeConfig
29
- } from "./chunk-5S5CF3ER.js";
30
- import "./chunk-MO4EEYFW.js";
29
+ } from "./chunk-4ZO3ZOPM.js";
31
30
  export {
32
31
  ContextEnricher,
33
32
  DEFAULT_AUTH_CONFIG,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  doctorCommand
4
- } from "./chunk-KFHK6EBI.js";
4
+ } from "./chunk-OSYMVGWX.js";
5
5
  import "./chunk-2QNZ6PVD.js";
6
6
  import "./chunk-4NCFWYGG.js";
7
7
  import "./chunk-YO6DVTL7.js";
@@ -0,0 +1,251 @@
1
+ #!/usr/bin/env node
2
+ import "./chunk-MO4EEYFW.js";
3
+
4
+ // src/commands/drift.ts
5
+ import * as fs from "fs";
6
+ import * as path from "path";
7
+ import * as crypto from "crypto";
8
+ import { execSync } from "child_process";
9
+ import chalk from "chalk";
10
+ function normalizeForHash(content) {
11
+ return content.split("\n").map((l) => l.trimEnd()).filter((l) => l.trim().length > 0).join("\n").replace(/\s+/g, " ").trim();
12
+ }
13
+ function parseHunks(diff) {
14
+ const hunks = [];
15
+ const pattern = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/gm;
16
+ let match;
17
+ while ((match = pattern.exec(diff)) !== null) {
18
+ hunks.push({
19
+ oldStart: parseInt(match[1], 10),
20
+ oldCount: match[2] !== void 0 ? parseInt(match[2], 10) : 1,
21
+ newCount: match[4] !== void 0 ? parseInt(match[4], 10) : 1
22
+ });
23
+ }
24
+ return hunks;
25
+ }
26
+ function computeShift(rootDir, filePath, fromCommit, startLine, endLine) {
27
+ let diff;
28
+ try {
29
+ diff = execSync(
30
+ `git diff ${fromCommit}..HEAD --unified=0 -- "${filePath}"`,
31
+ { cwd: rootDir, encoding: "utf8", timeout: 5e3 }
32
+ );
33
+ } catch {
34
+ return null;
35
+ }
36
+ if (!diff.trim()) {
37
+ return null;
38
+ }
39
+ const hunks = parseHunks(diff);
40
+ let offset = 0;
41
+ for (const hunk of hunks) {
42
+ const hunkEnd = hunk.oldStart + hunk.oldCount;
43
+ if (hunkEnd <= startLine) {
44
+ offset += hunk.newCount - hunk.oldCount;
45
+ continue;
46
+ }
47
+ if (hunk.oldStart < endLine) {
48
+ return null;
49
+ }
50
+ break;
51
+ }
52
+ if (offset === 0) return null;
53
+ return { newStart: startLine + offset, newEnd: endLine + offset };
54
+ }
55
+ function healPurposeFile(rootDir, purposePath, anchorFile, oldStart, oldEnd, newStart, newEnd) {
56
+ const absPath = path.isAbsolute(purposePath) ? purposePath : path.join(rootDir, purposePath);
57
+ if (!fs.existsSync(absPath)) return false;
58
+ try {
59
+ const content = fs.readFileSync(absPath, "utf8");
60
+ const oldRef = oldStart === oldEnd ? `${anchorFile}:${oldStart}` : `${anchorFile}:${oldStart}-${oldEnd}`;
61
+ const newRef = newStart === newEnd ? `${anchorFile}:${newStart}` : `${anchorFile}:${newStart}-${newEnd}`;
62
+ if (!content.includes(oldRef)) return false;
63
+ fs.writeFileSync(absPath, content.replace(oldRef, newRef), "utf8");
64
+ return true;
65
+ } catch {
66
+ return false;
67
+ }
68
+ }
69
+ async function driftCheckCommand(options) {
70
+ const rootDir = process.cwd();
71
+ const dbPath = path.join(rootDir, ".paradigm", "aspect-graph.db");
72
+ if (!fs.existsSync(dbPath)) {
73
+ if (options.json) {
74
+ console.log(JSON.stringify({ driftedCount: 0, healedCount: 0, cleanCount: 0, missingCount: 0, details: [] }));
75
+ } else {
76
+ console.log(chalk.gray("No aspect-graph.db found. Run paradigm_aspect_check to initialize."));
77
+ }
78
+ return;
79
+ }
80
+ const autoHeal = options.autoHeal !== false;
81
+ try {
82
+ const initSqlJs = (await import("sql.js")).default;
83
+ const SQL = await initSqlJs();
84
+ const buffer = fs.readFileSync(dbPath);
85
+ const db = new SQL.Database(buffer);
86
+ const results = [];
87
+ try {
88
+ const stmt = db.prepare("SELECT id, aspect_id, file_path, start_line, end_line, content_hash, normalized_hash, materialized_at_commit, drifted FROM anchors");
89
+ const anchors = [];
90
+ while (stmt.step()) {
91
+ const row = stmt.getAsObject();
92
+ anchors.push(row);
93
+ }
94
+ stmt.free();
95
+ for (const anchor of anchors) {
96
+ const absFile = path.isAbsolute(anchor.file_path) ? anchor.file_path : path.join(rootDir, anchor.file_path);
97
+ if (!fs.existsSync(absFile)) {
98
+ results.push({
99
+ aspectId: anchor.aspect_id,
100
+ path: anchor.file_path,
101
+ startLine: anchor.start_line,
102
+ endLine: anchor.end_line,
103
+ status: "missing"
104
+ });
105
+ continue;
106
+ }
107
+ const fileContent = fs.readFileSync(absFile, "utf8");
108
+ const lines = fileContent.split("\n");
109
+ const startIdx = Math.max(0, anchor.start_line - 1);
110
+ const endIdx = Math.min(lines.length, anchor.end_line);
111
+ const slice = lines.slice(startIdx, endIdx).join("\n");
112
+ const exactHash = crypto.createHash("sha256").update(slice).digest("hex");
113
+ if (anchor.content_hash != null && exactHash === anchor.content_hash) {
114
+ if (anchor.drifted === 1) {
115
+ db.run("UPDATE anchors SET drifted = 0 WHERE id = ?", [anchor.id]);
116
+ }
117
+ results.push({
118
+ aspectId: anchor.aspect_id,
119
+ path: anchor.file_path,
120
+ startLine: anchor.start_line,
121
+ endLine: anchor.end_line,
122
+ status: "clean"
123
+ });
124
+ continue;
125
+ }
126
+ const normHash = crypto.createHash("sha256").update(normalizeForHash(slice)).digest("hex");
127
+ if (anchor.normalized_hash != null && normHash === anchor.normalized_hash) {
128
+ db.run("UPDATE anchors SET content_hash = ?, drifted = 0 WHERE id = ?", [exactHash, anchor.id]);
129
+ results.push({
130
+ aspectId: anchor.aspect_id,
131
+ path: anchor.file_path,
132
+ startLine: anchor.start_line,
133
+ endLine: anchor.end_line,
134
+ status: "cosmetic"
135
+ });
136
+ continue;
137
+ }
138
+ if (anchor.content_hash == null && anchor.normalized_hash == null) {
139
+ db.run(
140
+ "UPDATE anchors SET content_hash = ?, normalized_hash = ?, drifted = 0 WHERE id = ?",
141
+ [exactHash, normHash, anchor.id]
142
+ );
143
+ results.push({
144
+ aspectId: anchor.aspect_id,
145
+ path: anchor.file_path,
146
+ startLine: anchor.start_line,
147
+ endLine: anchor.end_line,
148
+ status: "clean"
149
+ });
150
+ continue;
151
+ }
152
+ let resolved = false;
153
+ if (anchor.materialized_at_commit) {
154
+ const shift = computeShift(rootDir, anchor.file_path, anchor.materialized_at_commit, anchor.start_line, anchor.end_line);
155
+ if (shift) {
156
+ const shiftedSlice = lines.slice(Math.max(0, shift.newStart - 1), Math.min(lines.length, shift.newEnd)).join("\n");
157
+ const shiftedHash = crypto.createHash("sha256").update(shiftedSlice).digest("hex");
158
+ if (anchor.content_hash != null && shiftedHash === anchor.content_hash || anchor.normalized_hash != null && crypto.createHash("sha256").update(normalizeForHash(shiftedSlice)).digest("hex") === anchor.normalized_hash) {
159
+ if (autoHeal) {
160
+ const newHash = crypto.createHash("sha256").update(shiftedSlice).digest("hex");
161
+ db.run(
162
+ "UPDATE anchors SET start_line = ?, end_line = ?, content_hash = ?, drifted = 0 WHERE id = ?",
163
+ [shift.newStart, shift.newEnd, newHash, anchor.id]
164
+ );
165
+ const aspectStmt = db.prepare("SELECT defined_in FROM aspects WHERE id = ?");
166
+ aspectStmt.bind([anchor.aspect_id]);
167
+ if (aspectStmt.step()) {
168
+ const aspectRow = aspectStmt.getAsObject();
169
+ healPurposeFile(
170
+ rootDir,
171
+ aspectRow.defined_in,
172
+ anchor.file_path,
173
+ anchor.start_line,
174
+ anchor.end_line,
175
+ shift.newStart,
176
+ shift.newEnd
177
+ );
178
+ }
179
+ aspectStmt.free();
180
+ }
181
+ results.push({
182
+ aspectId: anchor.aspect_id,
183
+ path: anchor.file_path,
184
+ startLine: autoHeal ? shift.newStart : anchor.start_line,
185
+ endLine: autoHeal ? shift.newEnd : anchor.end_line,
186
+ status: "shifted",
187
+ autoHealed: autoHeal
188
+ });
189
+ resolved = true;
190
+ }
191
+ }
192
+ }
193
+ if (!resolved) {
194
+ db.run("UPDATE anchors SET drifted = 1 WHERE id = ?", [anchor.id]);
195
+ results.push({
196
+ aspectId: anchor.aspect_id,
197
+ path: anchor.file_path,
198
+ startLine: anchor.start_line,
199
+ endLine: anchor.end_line,
200
+ status: "modified"
201
+ });
202
+ }
203
+ }
204
+ const data = db.export();
205
+ fs.writeFileSync(dbPath, Buffer.from(data));
206
+ } finally {
207
+ db.close();
208
+ }
209
+ const summary = {
210
+ driftedCount: results.filter((r) => r.status === "modified").length,
211
+ healedCount: results.filter((r) => r.status === "shifted" && r.autoHealed).length,
212
+ cleanCount: results.filter((r) => r.status === "clean" || r.status === "cosmetic").length,
213
+ missingCount: results.filter((r) => r.status === "missing").length,
214
+ details: results
215
+ };
216
+ if (options.json) {
217
+ console.log(JSON.stringify(summary));
218
+ } else {
219
+ console.log(chalk.blue("\nAspect Drift Check\n"));
220
+ if (summary.healedCount > 0) {
221
+ console.log(chalk.green(` Auto-healed: ${summary.healedCount} shifted anchor(s)`));
222
+ }
223
+ if (summary.cleanCount > 0) {
224
+ console.log(chalk.green(` Clean: ${summary.cleanCount} anchor(s)`));
225
+ }
226
+ if (summary.driftedCount > 0) {
227
+ console.log(chalk.red(` Drifted: ${summary.driftedCount} anchor(s) (content changed)`));
228
+ for (const d of results.filter((d2) => d2.status === "modified")) {
229
+ console.log(chalk.red(` ${d.aspectId}: ${d.path}:${d.startLine}-${d.endLine}`));
230
+ }
231
+ }
232
+ if (summary.missingCount > 0) {
233
+ console.log(chalk.yellow(` Missing: ${summary.missingCount} anchor file(s) deleted`));
234
+ }
235
+ if (summary.driftedCount === 0 && summary.missingCount === 0) {
236
+ console.log(chalk.green("\n All anchors are clean.\n"));
237
+ } else {
238
+ console.log(chalk.gray("\n Run paradigm_aspect_check to review and fix.\n"));
239
+ }
240
+ }
241
+ } catch (err) {
242
+ if (options.json) {
243
+ console.log(JSON.stringify({ driftedCount: 0, healedCount: 0, cleanCount: 0, missingCount: 0, details: [], error: String(err) }));
244
+ } else {
245
+ console.log(chalk.red(`Drift check failed: ${err}`));
246
+ }
247
+ }
248
+ }
249
+ export {
250
+ driftCheckCommand
251
+ };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-HPC3JAUP.js";
2
+ import "./chunk-MW5DMGBB.js";
3
3
  import {
4
4
  log
5
5
  } from "./chunk-4NCFWYGG.js";
@@ -911,7 +911,7 @@ async function habitsStatusCommand(options) {
911
911
  const enabled = getEnabledHabits(habits);
912
912
  let practiceData = null;
913
913
  try {
914
- const { SentinelStorage } = await import("./dist-OLFOTUHS.js");
914
+ const { SentinelStorage } = await import("./dist-6SX5ZKKF.js");
915
915
  const sentinelDir = path3.join(rootDir, ".paradigm", "sentinel");
916
916
  if (fs2.existsSync(sentinelDir)) {
917
917
  const storage = new SentinelStorage(sentinelDir);
@@ -1279,7 +1279,7 @@ async function habitsCheckCommand(options) {
1279
1279
  try {
1280
1280
  const sentinelDir = path3.join(rootDir, ".paradigm", "sentinel");
1281
1281
  if (fs2.existsSync(sentinelDir)) {
1282
- const { SentinelStorage } = await import("./dist-OLFOTUHS.js");
1282
+ const { SentinelStorage } = await import("./dist-6SX5ZKKF.js");
1283
1283
  const storage = new SentinelStorage(sentinelDir);
1284
1284
  for (const e of evaluation.evaluations) {
1285
1285
  storage.recordPracticeEvent({
@@ -3,7 +3,7 @@ import {
3
3
  hooksInstallCommand,
4
4
  hooksStatusCommand,
5
5
  hooksUninstallCommand
6
- } from "./chunk-M2XMTJHQ.js";
6
+ } from "./chunk-DS5QY37M.js";
7
7
  import "./chunk-MO4EEYFW.js";
8
8
  export {
9
9
  hooksInstallCommand,