task-summary-extractor 8.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.
- package/ARCHITECTURE.md +605 -0
- package/EXPLORATION.md +451 -0
- package/QUICK_START.md +272 -0
- package/README.md +544 -0
- package/bin/taskex.js +64 -0
- package/package.json +63 -0
- package/process_and_upload.js +107 -0
- package/prompt.json +265 -0
- package/setup.js +505 -0
- package/src/config.js +327 -0
- package/src/logger.js +355 -0
- package/src/pipeline.js +2006 -0
- package/src/renderers/markdown.js +968 -0
- package/src/services/firebase.js +106 -0
- package/src/services/gemini.js +779 -0
- package/src/services/git.js +329 -0
- package/src/services/video.js +305 -0
- package/src/utils/adaptive-budget.js +266 -0
- package/src/utils/change-detector.js +466 -0
- package/src/utils/cli.js +415 -0
- package/src/utils/context-manager.js +499 -0
- package/src/utils/cost-tracker.js +156 -0
- package/src/utils/deep-dive.js +549 -0
- package/src/utils/diff-engine.js +315 -0
- package/src/utils/dynamic-mode.js +567 -0
- package/src/utils/focused-reanalysis.js +317 -0
- package/src/utils/format.js +32 -0
- package/src/utils/fs.js +39 -0
- package/src/utils/global-config.js +315 -0
- package/src/utils/health-dashboard.js +216 -0
- package/src/utils/inject-cli-flags.js +58 -0
- package/src/utils/json-parser.js +245 -0
- package/src/utils/learning-loop.js +301 -0
- package/src/utils/progress-updater.js +451 -0
- package/src/utils/progress.js +166 -0
- package/src/utils/prompt.js +32 -0
- package/src/utils/quality-gate.js +429 -0
- package/src/utils/retry.js +129 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Storage — init, upload, and existence checks.
|
|
3
|
+
*
|
|
4
|
+
* Improvements:
|
|
5
|
+
* - Retry logic with exponential backoff for transient failures
|
|
6
|
+
* - No process.exit() — throws descriptive errors instead
|
|
7
|
+
* - Upload progress tracking for large files
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { FIREBASE_CONFIG, MIME_MAP } = require('../config');
|
|
15
|
+
const { withRetry } = require('../utils/retry');
|
|
16
|
+
const { ref, uploadBytes, getDownloadURL } = require('firebase/storage');
|
|
17
|
+
|
|
18
|
+
// Cached Firebase instances — avoid re-initializing
|
|
19
|
+
let _app = null;
|
|
20
|
+
let _storage = null;
|
|
21
|
+
let _auth = null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initialize Firebase app, storage, and anonymous auth.
|
|
25
|
+
* Returns { storage, authenticated }.
|
|
26
|
+
* Safe to call multiple times — caches the instance.
|
|
27
|
+
*/
|
|
28
|
+
async function initFirebase() {
|
|
29
|
+
if (_storage) {
|
|
30
|
+
return { storage: _storage, authenticated: !!_auth };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { initializeApp } = require('firebase/app');
|
|
34
|
+
const { getStorage } = require('firebase/storage');
|
|
35
|
+
const { getAuth, signInAnonymously } = require('firebase/auth');
|
|
36
|
+
|
|
37
|
+
_app = initializeApp(FIREBASE_CONFIG);
|
|
38
|
+
_storage = getStorage(_app);
|
|
39
|
+
|
|
40
|
+
let authenticated = false;
|
|
41
|
+
try {
|
|
42
|
+
const auth = getAuth(_app);
|
|
43
|
+
await signInAnonymously(auth);
|
|
44
|
+
_auth = auth;
|
|
45
|
+
authenticated = true;
|
|
46
|
+
console.log(' Firebase: anonymous sign-in OK');
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.warn(` Firebase: anonymous auth failed (${err.message})`);
|
|
49
|
+
console.warn(' → Storage uploads will be skipped.');
|
|
50
|
+
console.warn(' → To fix: enable Anonymous sign-in in Firebase Console → Authentication → Sign-in method');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return { storage: _storage, authenticated };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Upload a local file to Firebase Storage with retry.
|
|
58
|
+
* Returns the download URL.
|
|
59
|
+
*
|
|
60
|
+
* @param {object} storage - Firebase storage instance
|
|
61
|
+
* @param {string} filePath - Local file path
|
|
62
|
+
* @param {string} storagePath - Target path in Firebase Storage
|
|
63
|
+
* @returns {Promise<string>} Download URL
|
|
64
|
+
*/
|
|
65
|
+
async function uploadToStorage(storage, filePath, storagePath) {
|
|
66
|
+
|
|
67
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
68
|
+
const contentType = MIME_MAP[ext] || 'application/octet-stream';
|
|
69
|
+
|
|
70
|
+
if (!fs.existsSync(filePath)) {
|
|
71
|
+
throw new Error(`File not found for upload: ${filePath}`);
|
|
72
|
+
}
|
|
73
|
+
const fileBuffer = await fs.promises.readFile(filePath);
|
|
74
|
+
|
|
75
|
+
return withRetry(async () => {
|
|
76
|
+
const fileRef = ref(storage, storagePath);
|
|
77
|
+
await uploadBytes(fileRef, fileBuffer, { contentType });
|
|
78
|
+
const url = await getDownloadURL(fileRef);
|
|
79
|
+
return url;
|
|
80
|
+
}, {
|
|
81
|
+
label: `Firebase upload (${path.basename(filePath)})`,
|
|
82
|
+
maxRetries: 3,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Check if a file already exists in Firebase Storage.
|
|
88
|
+
* Returns the download URL if it exists, null otherwise.
|
|
89
|
+
* Retries on transient network errors.
|
|
90
|
+
*/
|
|
91
|
+
async function storageExists(storage, storagePath) {
|
|
92
|
+
try {
|
|
93
|
+
return await withRetry(async () => {
|
|
94
|
+
const fileRef = ref(storage, storagePath);
|
|
95
|
+
return await getDownloadURL(fileRef);
|
|
96
|
+
}, {
|
|
97
|
+
label: `Firebase exists check (${storagePath})`,
|
|
98
|
+
maxRetries: 2,
|
|
99
|
+
baseDelay: 1000,
|
|
100
|
+
});
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = { initFirebase, uploadToStorage, storageExists };
|