@cccarv82/freya 2.17.0 → 2.17.2
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/cli/auto-update.js +2 -4
- package/cli/init.js +4 -5
- package/cli/web-ui.js +1 -1
- package/cli/web.js +10 -0
- package/package.json +1 -1
- package/templates/base/scripts/generate-weekly-report.js +0 -128
package/cli/auto-update.js
CHANGED
|
@@ -90,12 +90,10 @@ async function autoUpdate(workspaceDir) {
|
|
|
90
90
|
return { updated: false, version: installedVersion };
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
//
|
|
94
|
-
const scriptsDir = path.join(workspaceDir, 'scripts');
|
|
93
|
+
// If workspace dir doesn't exist at all, skip (will be handled by auto-init in cmdWeb)
|
|
95
94
|
try {
|
|
96
|
-
fs.accessSync(
|
|
95
|
+
fs.accessSync(workspaceDir);
|
|
97
96
|
} catch {
|
|
98
|
-
// Not a workspace, skip
|
|
99
97
|
return { updated: false, version: installedVersion };
|
|
100
98
|
}
|
|
101
99
|
|
package/cli/init.js
CHANGED
|
@@ -64,9 +64,9 @@ function copyDirRecursive(srcDir, destDir, force, summary, options = {}) {
|
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
// Always force-update
|
|
68
|
-
const
|
|
69
|
-
copyDirRecursive(src, dest, force ||
|
|
67
|
+
// Always force-update app code directories (scripts, .agent) — not user data
|
|
68
|
+
const isAppCode = ent.name === 'scripts' || ent.name === '.agent';
|
|
69
|
+
copyDirRecursive(src, dest, force || isAppCode, summary, options);
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -85,8 +85,7 @@ function ensurePackageJson(targetDir, force, summary) {
|
|
|
85
85
|
const scriptsToEnsure = {
|
|
86
86
|
health: 'node scripts/validate-data.js && node scripts/validate-structure.js',
|
|
87
87
|
migrate: 'node scripts/migrate-data.js',
|
|
88
|
-
|
|
89
|
-
'sm-weekly': 'node scripts/generate-sm-weekly-report.js',
|
|
88
|
+
'sm-weekly': 'node scripts/generate-sm-weekly-report.js',
|
|
90
89
|
daily: 'node scripts/generate-daily-summary.js',
|
|
91
90
|
status: 'node scripts/generate-executive-report.js',
|
|
92
91
|
blockers: 'node scripts/generate-blockers-report.js'
|
package/cli/web-ui.js
CHANGED
|
@@ -1823,7 +1823,7 @@
|
|
|
1823
1823
|
if (!el) return;
|
|
1824
1824
|
const anomalies = (r && r.anomalies) ? r.anomalies : {};
|
|
1825
1825
|
const tasksMissing = anomalies.tasksMissingProject || { count: 0, samples: [] };
|
|
1826
|
-
const statusMissing = anomalies.statusMissingHistory || { count: 0, samples: [] };
|
|
1826
|
+
const statusMissing = anomalies.projectsMissingHistory || anomalies.statusMissingHistory || { count: 0, samples: [] };
|
|
1827
1827
|
|
|
1828
1828
|
const rows = [];
|
|
1829
1829
|
const pushRow = (label, data) => {
|
package/cli/web.js
CHANGED
|
@@ -2270,6 +2270,16 @@ async function cmdWeb({ port, dir, open, dev }) {
|
|
|
2270
2270
|
await ready;
|
|
2271
2271
|
}
|
|
2272
2272
|
|
|
2273
|
+
// Auto-init workspace if not yet initialized (first run)
|
|
2274
|
+
if (!looksLikeFreyaWorkspace(wsDir)) {
|
|
2275
|
+
try {
|
|
2276
|
+
await initWorkspace({ targetDir: wsDir, force: false, forceData: false, forceLogs: false });
|
|
2277
|
+
console.log('[FREYA] Workspace initialized at', wsDir);
|
|
2278
|
+
} catch (e) {
|
|
2279
|
+
console.error('[FREYA] Warning: auto-init failed:', e.message || String(e));
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2273
2283
|
// Auto-update workspace scripts/deps if Freya version changed
|
|
2274
2284
|
try {
|
|
2275
2285
|
const { autoUpdate } = require('./auto-update');
|
package/package.json
CHANGED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* generate-weekly-report.js
|
|
3
|
-
* Generates a weekly Markdown report aggregating Tasks, Blockers, Career entries,
|
|
4
|
-
* and Project Updates from the SQLite database.
|
|
5
|
-
*
|
|
6
|
-
* Usage: node scripts/generate-weekly-report.js
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
const { toIsoDate, safeParseToMs } = require('./lib/date-utils');
|
|
13
|
-
const DataManager = require('./lib/DataManager');
|
|
14
|
-
const { ready } = require('./lib/DataLayer');
|
|
15
|
-
|
|
16
|
-
// --- Configuration (BUG-30: use FREYA_WORKSPACE_DIR instead of __dirname) ---
|
|
17
|
-
const WORKSPACE_DIR = process.env.FREYA_WORKSPACE_DIR
|
|
18
|
-
? path.resolve(process.env.FREYA_WORKSPACE_DIR)
|
|
19
|
-
: path.join(__dirname, '..'); // fallback: scripts/ is one level below workspace root
|
|
20
|
-
|
|
21
|
-
const REPORT_DIR = path.join(WORKSPACE_DIR, 'docs', 'reports');
|
|
22
|
-
|
|
23
|
-
// --- Date Logic ---
|
|
24
|
-
const now = new Date();
|
|
25
|
-
const oneDay = 24 * 60 * 60 * 1000;
|
|
26
|
-
|
|
27
|
-
function isWithinWeek(dateStr) {
|
|
28
|
-
const ms = safeParseToMs(dateStr);
|
|
29
|
-
if (!Number.isFinite(ms)) return false;
|
|
30
|
-
const sevenDaysAgo = now.getTime() - (7 * oneDay);
|
|
31
|
-
return ms >= sevenDaysAgo && ms <= now.getTime();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getFormattedDate() {
|
|
35
|
-
return toIsoDate(now);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getFormattedTime() {
|
|
39
|
-
const hh = String(now.getHours()).padStart(2, '0');
|
|
40
|
-
const mm = String(now.getMinutes()).padStart(2, '0');
|
|
41
|
-
const ss = String(now.getSeconds()).padStart(2, '0');
|
|
42
|
-
return `${hh}${mm}${ss}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// --- Report Generation ---
|
|
46
|
-
async function generateWeeklyReport() {
|
|
47
|
-
await ready;
|
|
48
|
-
|
|
49
|
-
const start = new Date(now.getTime() - 7 * oneDay);
|
|
50
|
-
const end = now;
|
|
51
|
-
|
|
52
|
-
const dm = new DataManager();
|
|
53
|
-
|
|
54
|
-
// Fetch data from SQLite
|
|
55
|
-
const { completed: completedTasks } = dm.getTasks(start, end);
|
|
56
|
-
const { open: openBlockers, resolvedRecent } = dm.getBlockers(start, end);
|
|
57
|
-
const projectUpdates = dm.getProjectUpdates(start, end);
|
|
58
|
-
const careerEntries = dm.getCareerEntries ? dm.getCareerEntries(start, end) : [];
|
|
59
|
-
|
|
60
|
-
// Ensure output dir exists
|
|
61
|
-
if (!fs.existsSync(REPORT_DIR)) {
|
|
62
|
-
fs.mkdirSync(REPORT_DIR, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const reportDate = getFormattedDate();
|
|
66
|
-
const reportTime = getFormattedTime();
|
|
67
|
-
let report = `# Weekly Report - ${reportDate}\n\n`;
|
|
68
|
-
|
|
69
|
-
// Projects
|
|
70
|
-
report += '## Project Updates\n';
|
|
71
|
-
if (projectUpdates.length > 0) {
|
|
72
|
-
projectUpdates.forEach(p => {
|
|
73
|
-
report += `### ${p.client || 'Unknown'} - ${p.project || p.slug || 'Unknown'}\n`;
|
|
74
|
-
const events = Array.isArray(p.events) ? p.events : [];
|
|
75
|
-
events.forEach(e => {
|
|
76
|
-
const dateStr = e.date ? String(e.date).slice(0, 10) : 'Unknown Date';
|
|
77
|
-
report += `- **${dateStr}**: ${e.content || ''}\n`;
|
|
78
|
-
});
|
|
79
|
-
report += '\n';
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
report += 'No project updates recorded this week.\n\n';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Completed Tasks
|
|
86
|
-
report += '## Completed Tasks\n';
|
|
87
|
-
if (completedTasks.length > 0) {
|
|
88
|
-
completedTasks.forEach(t => {
|
|
89
|
-
const projectTag = t.projectSlug || t.project_slug ? `[${t.projectSlug || t.project_slug}] ` : '';
|
|
90
|
-
report += `- ${projectTag}${t.description}\n`;
|
|
91
|
-
});
|
|
92
|
-
} else {
|
|
93
|
-
report += 'No tasks completed this week.\n';
|
|
94
|
-
}
|
|
95
|
-
report += '\n';
|
|
96
|
-
|
|
97
|
-
// Open Blockers
|
|
98
|
-
report += '## Open Blockers\n';
|
|
99
|
-
if (openBlockers.length > 0) {
|
|
100
|
-
openBlockers.forEach(b => {
|
|
101
|
-
const sev = b.severity ? `[${b.severity}] ` : '';
|
|
102
|
-
report += `- ${sev}${b.title}\n`;
|
|
103
|
-
});
|
|
104
|
-
} else {
|
|
105
|
-
report += 'No open blockers.\n';
|
|
106
|
-
}
|
|
107
|
-
report += '\n';
|
|
108
|
-
|
|
109
|
-
// Career entries (if DataManager supports it)
|
|
110
|
-
if (Array.isArray(careerEntries) && careerEntries.length > 0) {
|
|
111
|
-
report += '## Career Highlights\n';
|
|
112
|
-
careerEntries.forEach(e => {
|
|
113
|
-
report += `- **[${e.type || 'Note'}]**: ${e.description || e.content || ''}\n`;
|
|
114
|
-
});
|
|
115
|
-
report += '\n';
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 3. Save and Output
|
|
119
|
-
const outputPath = path.join(REPORT_DIR, `weekly-${reportDate}-${reportTime}.md`);
|
|
120
|
-
fs.writeFileSync(outputPath, report);
|
|
121
|
-
|
|
122
|
-
console.log(`Report generated at: ${outputPath}`);
|
|
123
|
-
console.log('---------------------------------------------------');
|
|
124
|
-
console.log(report);
|
|
125
|
-
console.log('---------------------------------------------------');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
generateWeeklyReport().catch(err => { console.error(err); process.exit(1); });
|