@a-company/paradigm 5.9.0 → 5.10.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 (29) hide show
  1. package/dist/{accept-orchestration-GX2YRWM4.js → accept-orchestration-UQLM7PTQ.js} +4 -4
  2. package/dist/{agent-loader-X7TDYLFL.js → agent-loader-TFIANSF4.js} +1 -1
  3. package/dist/agent-state-S5DAWPTF.js +24 -0
  4. package/dist/{chunk-3UCH56D5.js → chunk-4BLYIB7J.js} +270 -928
  5. package/dist/chunk-4L3UTYQX.js +677 -0
  6. package/dist/chunk-54LTTQBH.js +138 -0
  7. package/dist/chunk-5OUOLN6M.js +659 -0
  8. package/dist/{chunk-SDDCVUCV.js → chunk-CL7JSK52.js} +23 -0
  9. package/dist/{chunk-MA7G4CTI.js → chunk-RJE5G7WO.js} +27 -1
  10. package/dist/{chunk-EI32ZBE6.js → chunk-RTHA3XRE.js} +19 -672
  11. package/dist/{chunk-V7BZBBI6.js → chunk-VPPK3SY4.js} +1 -1
  12. package/dist/{chunk-WQITYKHM.js → chunk-YRZ5RPEB.js} +7 -7
  13. package/dist/{diff-RQLLNAFI.js → diff-D4X53HAC.js} +4 -4
  14. package/dist/{docs-AIY6VNF7.js → docs-QIYKO3BR.js} +1 -1
  15. package/dist/index.js +19 -19
  16. package/dist/mcp.js +140 -66
  17. package/dist/model-discovery-D2H3VBGC.js +8 -0
  18. package/dist/{nomination-engine-LLREC5BZ.js → nomination-engine-RV5CNO5B.js} +2 -2
  19. package/dist/{orchestrate-XZA33TJC.js → orchestrate-JLILBBJE.js} +4 -4
  20. package/dist/{reindex-U2HEB6GW.js → reindex-5LTD53ZC.js} +3 -2
  21. package/dist/{serve-QWWJP2EW.js → serve-CAH3PHE7.js} +1 -1
  22. package/dist/session-tracker-C4BMD5WG.js +13 -0
  23. package/dist/{session-work-log-KDOH4GER.js → session-work-log-MZ47OAPB.js} +1 -1
  24. package/dist/{shift-VJUGMADR.js → shift-D2JOHHBF.js} +33 -5
  25. package/dist/{spawn-AW6GDECS.js → spawn-RCHNXDHE.js} +4 -4
  26. package/dist/{team-7HG7XK5C.js → team-O5MIIFMA.js} +6 -5
  27. package/package.json +1 -1
  28. package/dist/{chunk-LSRABQIY.js → chunk-45MUDW6E.js} +3 -3
  29. /package/dist/{platform-server-U5L2G3EU.js → platform-server-H5YO3DQD.js} +0 -0
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+
3
+ // ../paradigm-mcp/src/utils/agent-state.ts
4
+ import * as fs from "fs";
5
+ import * as path from "path";
6
+ import * as os from "os";
7
+ import * as yaml from "js-yaml";
8
+ var PROJECT_STATE_DIR = ".paradigm/agent-state";
9
+ var GLOBAL_AGENTS_DIR = path.join(os.homedir(), ".paradigm", "agents");
10
+ function loadAgentState(agentId, rootDir) {
11
+ const statePath = path.join(rootDir, PROJECT_STATE_DIR, `${agentId}.yaml`);
12
+ if (!fs.existsSync(statePath)) return null;
13
+ try {
14
+ const content = fs.readFileSync(statePath, "utf8");
15
+ return yaml.load(content);
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+ function saveAgentState(agentId, rootDir, state) {
21
+ const stateDir = path.join(rootDir, PROJECT_STATE_DIR);
22
+ if (!fs.existsSync(stateDir)) {
23
+ fs.mkdirSync(stateDir, { recursive: true });
24
+ }
25
+ const statePath = path.join(stateDir, `${agentId}.yaml`);
26
+ fs.writeFileSync(statePath, yaml.dump(state, { lineWidth: 120, noRefs: true, sortKeys: false }), "utf8");
27
+ }
28
+ function recordAgentSession(agentId, rootDir, session) {
29
+ const existing = loadAgentState(agentId, rootDir);
30
+ const projectName = path.basename(rootDir);
31
+ const state = {
32
+ id: agentId,
33
+ project: projectName,
34
+ lastSession: {
35
+ date: (/* @__PURE__ */ new Date()).toISOString(),
36
+ sessionId: session.sessionId,
37
+ summary: session.summary,
38
+ filesReviewed: session.filesReviewed,
39
+ symbolsTouched: session.symbolsTouched,
40
+ decisions: session.decisions
41
+ },
42
+ pendingWork: session.pendingWork || existing?.pendingWork || [],
43
+ recentPatterns: session.patterns || existing?.recentPatterns || [],
44
+ sessionsOnProject: (existing?.sessionsOnProject || 0) + 1,
45
+ lastPurposeUpdate: existing?.lastPurposeUpdate
46
+ };
47
+ saveAgentState(agentId, rootDir, state);
48
+ updateGlobalAgentState(agentId, projectName);
49
+ return state;
50
+ }
51
+ function addPendingWork(agentId, rootDir, items) {
52
+ const state = loadAgentState(agentId, rootDir);
53
+ if (!state) return;
54
+ state.pendingWork = [.../* @__PURE__ */ new Set([...state.pendingWork, ...items])];
55
+ saveAgentState(agentId, rootDir, state);
56
+ }
57
+ function completePendingWork(agentId, rootDir, completedItems) {
58
+ const state = loadAgentState(agentId, rootDir);
59
+ if (!state) return;
60
+ const completedSet = new Set(completedItems.map((i) => i.toLowerCase()));
61
+ state.pendingWork = state.pendingWork.filter((item) => !completedSet.has(item.toLowerCase()));
62
+ saveAgentState(agentId, rootDir, state);
63
+ }
64
+ function addProjectPattern(agentId, rootDir, pattern) {
65
+ const state = loadAgentState(agentId, rootDir);
66
+ if (!state) return;
67
+ if (!state.recentPatterns.includes(pattern)) {
68
+ state.recentPatterns.push(pattern);
69
+ if (state.recentPatterns.length > 10) {
70
+ state.recentPatterns = state.recentPatterns.slice(-10);
71
+ }
72
+ saveAgentState(agentId, rootDir, state);
73
+ }
74
+ }
75
+ function loadGlobalAgentState(agentId) {
76
+ const statePath = path.join(GLOBAL_AGENTS_DIR, agentId, "state.yaml");
77
+ if (!fs.existsSync(statePath)) return null;
78
+ try {
79
+ const content = fs.readFileSync(statePath, "utf8");
80
+ return yaml.load(content);
81
+ } catch {
82
+ return null;
83
+ }
84
+ }
85
+ function updateGlobalAgentState(agentId, projectName) {
86
+ const stateDir = path.join(GLOBAL_AGENTS_DIR, agentId);
87
+ if (!fs.existsSync(stateDir)) {
88
+ fs.mkdirSync(stateDir, { recursive: true });
89
+ }
90
+ const statePath = path.join(stateDir, "state.yaml");
91
+ const existing = loadGlobalAgentState(agentId);
92
+ const now = (/* @__PURE__ */ new Date()).toISOString();
93
+ const history = existing?.projectHistory || [];
94
+ const projectEntry = history.find((h) => h.project === projectName);
95
+ if (projectEntry) {
96
+ projectEntry.sessions += 1;
97
+ projectEntry.lastActive = now;
98
+ } else {
99
+ history.push({ project: projectName, sessions: 1, lastActive: now });
100
+ }
101
+ history.sort((a, b) => b.lastActive.localeCompare(a.lastActive));
102
+ const state = {
103
+ id: agentId,
104
+ totalSessions: (existing?.totalSessions || 0) + 1,
105
+ lastActiveProject: projectName,
106
+ lastActiveDate: now,
107
+ projectHistory: history
108
+ };
109
+ fs.writeFileSync(statePath, yaml.dump(state, { lineWidth: 120, noRefs: true, sortKeys: false }), "utf8");
110
+ }
111
+ function loadAllAgentStates(rootDir) {
112
+ const stateDir = path.join(rootDir, PROJECT_STATE_DIR);
113
+ if (!fs.existsSync(stateDir)) return [];
114
+ try {
115
+ return fs.readdirSync(stateDir).filter((f) => f.endsWith(".yaml")).map((f) => {
116
+ try {
117
+ const content = fs.readFileSync(path.join(stateDir, f), "utf8");
118
+ return yaml.load(content);
119
+ } catch {
120
+ return null;
121
+ }
122
+ }).filter(Boolean);
123
+ } catch {
124
+ return [];
125
+ }
126
+ }
127
+
128
+ export {
129
+ loadAgentState,
130
+ saveAgentState,
131
+ recordAgentSession,
132
+ addPendingWork,
133
+ completePendingWork,
134
+ addProjectPattern,
135
+ loadGlobalAgentState,
136
+ updateGlobalAgentState,
137
+ loadAllAgentStates
138
+ };