qodewk 0.2.0 → 0.2.1
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/dist/index.cjs +146 -61
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1153,7 +1153,7 @@ var require_command = __commonJS({
|
|
|
1153
1153
|
"use strict";
|
|
1154
1154
|
var EventEmitter2 = require("events").EventEmitter;
|
|
1155
1155
|
var childProcess = require("child_process");
|
|
1156
|
-
var
|
|
1156
|
+
var path8 = require("path");
|
|
1157
1157
|
var fs7 = require("fs");
|
|
1158
1158
|
var process2 = require("process");
|
|
1159
1159
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -2153,9 +2153,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2153
2153
|
let launchWithNode = false;
|
|
2154
2154
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2155
2155
|
function findFile(baseDir, baseName) {
|
|
2156
|
-
const localBin =
|
|
2156
|
+
const localBin = path8.resolve(baseDir, baseName);
|
|
2157
2157
|
if (fs7.existsSync(localBin)) return localBin;
|
|
2158
|
-
if (sourceExt.includes(
|
|
2158
|
+
if (sourceExt.includes(path8.extname(baseName))) return void 0;
|
|
2159
2159
|
const foundExt = sourceExt.find(
|
|
2160
2160
|
(ext) => fs7.existsSync(`${localBin}${ext}`)
|
|
2161
2161
|
);
|
|
@@ -2173,17 +2173,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2173
2173
|
} catch {
|
|
2174
2174
|
resolvedScriptPath = this._scriptPath;
|
|
2175
2175
|
}
|
|
2176
|
-
executableDir =
|
|
2177
|
-
|
|
2176
|
+
executableDir = path8.resolve(
|
|
2177
|
+
path8.dirname(resolvedScriptPath),
|
|
2178
2178
|
executableDir
|
|
2179
2179
|
);
|
|
2180
2180
|
}
|
|
2181
2181
|
if (executableDir) {
|
|
2182
2182
|
let localFile = findFile(executableDir, executableFile);
|
|
2183
2183
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2184
|
-
const legacyName =
|
|
2184
|
+
const legacyName = path8.basename(
|
|
2185
2185
|
this._scriptPath,
|
|
2186
|
-
|
|
2186
|
+
path8.extname(this._scriptPath)
|
|
2187
2187
|
);
|
|
2188
2188
|
if (legacyName !== this._name) {
|
|
2189
2189
|
localFile = findFile(
|
|
@@ -2194,7 +2194,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2194
2194
|
}
|
|
2195
2195
|
executableFile = localFile || executableFile;
|
|
2196
2196
|
}
|
|
2197
|
-
launchWithNode = sourceExt.includes(
|
|
2197
|
+
launchWithNode = sourceExt.includes(path8.extname(executableFile));
|
|
2198
2198
|
let proc;
|
|
2199
2199
|
if (process2.platform !== "win32") {
|
|
2200
2200
|
if (launchWithNode) {
|
|
@@ -3041,7 +3041,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3041
3041
|
* @return {Command}
|
|
3042
3042
|
*/
|
|
3043
3043
|
nameFromFilename(filename) {
|
|
3044
|
-
this._name =
|
|
3044
|
+
this._name = path8.basename(filename, path8.extname(filename));
|
|
3045
3045
|
return this;
|
|
3046
3046
|
}
|
|
3047
3047
|
/**
|
|
@@ -3055,9 +3055,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3055
3055
|
* @param {string} [path]
|
|
3056
3056
|
* @return {(string|null|Command)}
|
|
3057
3057
|
*/
|
|
3058
|
-
executableDir(
|
|
3059
|
-
if (
|
|
3060
|
-
this._executableDir =
|
|
3058
|
+
executableDir(path9) {
|
|
3059
|
+
if (path9 === void 0) return this._executableDir;
|
|
3060
|
+
this._executableDir = path9;
|
|
3061
3061
|
return this;
|
|
3062
3062
|
}
|
|
3063
3063
|
/**
|
|
@@ -4956,10 +4956,10 @@ var require_segments = __commonJS({
|
|
|
4956
4956
|
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
|
|
4957
4957
|
const nodes = buildNodes(segs);
|
|
4958
4958
|
const graph = buildGraph(nodes, version);
|
|
4959
|
-
const
|
|
4959
|
+
const path8 = dijkstra.find_path(graph.map, "start", "end");
|
|
4960
4960
|
const optimizedSegs = [];
|
|
4961
|
-
for (let i2 = 1; i2 <
|
|
4962
|
-
optimizedSegs.push(graph.table[
|
|
4961
|
+
for (let i2 = 1; i2 < path8.length - 1; i2++) {
|
|
4962
|
+
optimizedSegs.push(graph.table[path8[i2]].node);
|
|
4963
4963
|
}
|
|
4964
4964
|
return exports2.fromArray(mergeSegments(optimizedSegs));
|
|
4965
4965
|
};
|
|
@@ -6001,10 +6001,10 @@ var require_src2 = __commonJS({
|
|
|
6001
6001
|
var fs_1 = require("fs");
|
|
6002
6002
|
var debug_1 = __importDefault(require_src());
|
|
6003
6003
|
var log = debug_1.default("@kwsites/file-exists");
|
|
6004
|
-
function check(
|
|
6005
|
-
log(`checking %s`,
|
|
6004
|
+
function check(path8, isFile, isDirectory) {
|
|
6005
|
+
log(`checking %s`, path8);
|
|
6006
6006
|
try {
|
|
6007
|
-
const stat = fs_1.statSync(
|
|
6007
|
+
const stat = fs_1.statSync(path8);
|
|
6008
6008
|
if (stat.isFile() && isFile) {
|
|
6009
6009
|
log(`[OK] path represents a file`);
|
|
6010
6010
|
return true;
|
|
@@ -6024,8 +6024,8 @@ var require_src2 = __commonJS({
|
|
|
6024
6024
|
throw e;
|
|
6025
6025
|
}
|
|
6026
6026
|
}
|
|
6027
|
-
function exists2(
|
|
6028
|
-
return check(
|
|
6027
|
+
function exists2(path8, type = exports2.READABLE) {
|
|
6028
|
+
return check(path8, (type & exports2.FILE) > 0, (type & exports2.FOLDER) > 0);
|
|
6029
6029
|
}
|
|
6030
6030
|
exports2.exists = exists2;
|
|
6031
6031
|
exports2.FILE = 1;
|
|
@@ -6090,6 +6090,7 @@ var require_dist2 = __commonJS({
|
|
|
6090
6090
|
|
|
6091
6091
|
// src/index.ts
|
|
6092
6092
|
var fs6 = __toESM(require("fs"), 1);
|
|
6093
|
+
var path7 = __toESM(require("path"), 1);
|
|
6093
6094
|
|
|
6094
6095
|
// ../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/esm.mjs
|
|
6095
6096
|
var import_index = __toESM(require_commander(), 1);
|
|
@@ -6605,8 +6606,8 @@ function getErrorMap() {
|
|
|
6605
6606
|
|
|
6606
6607
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
6607
6608
|
var makeIssue = (params) => {
|
|
6608
|
-
const { data, path:
|
|
6609
|
-
const fullPath = [...
|
|
6609
|
+
const { data, path: path8, errorMaps, issueData } = params;
|
|
6610
|
+
const fullPath = [...path8, ...issueData.path || []];
|
|
6610
6611
|
const fullIssue = {
|
|
6611
6612
|
...issueData,
|
|
6612
6613
|
path: fullPath
|
|
@@ -6722,11 +6723,11 @@ var errorUtil;
|
|
|
6722
6723
|
|
|
6723
6724
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
6724
6725
|
var ParseInputLazyPath = class {
|
|
6725
|
-
constructor(parent, value,
|
|
6726
|
+
constructor(parent, value, path8, key) {
|
|
6726
6727
|
this._cachedPath = [];
|
|
6727
6728
|
this.parent = parent;
|
|
6728
6729
|
this.data = value;
|
|
6729
|
-
this._path =
|
|
6730
|
+
this._path = path8;
|
|
6730
6731
|
this._key = key;
|
|
6731
6732
|
}
|
|
6732
6733
|
get path() {
|
|
@@ -10838,8 +10839,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
10838
10839
|
function forEachLineWithContent(input, callback) {
|
|
10839
10840
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
10840
10841
|
}
|
|
10841
|
-
function folderExists(
|
|
10842
|
-
return (0, import_file_exists.exists)(
|
|
10842
|
+
function folderExists(path8) {
|
|
10843
|
+
return (0, import_file_exists.exists)(path8, import_file_exists.FOLDER);
|
|
10843
10844
|
}
|
|
10844
10845
|
function append(target, item) {
|
|
10845
10846
|
if (Array.isArray(target)) {
|
|
@@ -11241,8 +11242,8 @@ function checkIsRepoRootTask() {
|
|
|
11241
11242
|
commands,
|
|
11242
11243
|
format: "utf-8",
|
|
11243
11244
|
onError,
|
|
11244
|
-
parser(
|
|
11245
|
-
return /^\.(git)?$/.test(
|
|
11245
|
+
parser(path8) {
|
|
11246
|
+
return /^\.(git)?$/.test(path8.trim());
|
|
11246
11247
|
}
|
|
11247
11248
|
};
|
|
11248
11249
|
}
|
|
@@ -11676,11 +11677,11 @@ function parseGrep(grep) {
|
|
|
11676
11677
|
const paths = /* @__PURE__ */ new Set();
|
|
11677
11678
|
const results = {};
|
|
11678
11679
|
forEachLineWithContent(grep, (input) => {
|
|
11679
|
-
const [
|
|
11680
|
-
paths.add(
|
|
11681
|
-
(results[
|
|
11680
|
+
const [path8, line, preview] = input.split(NULL);
|
|
11681
|
+
paths.add(path8);
|
|
11682
|
+
(results[path8] = results[path8] || []).push({
|
|
11682
11683
|
line: asNumber(line),
|
|
11683
|
-
path:
|
|
11684
|
+
path: path8,
|
|
11684
11685
|
preview
|
|
11685
11686
|
});
|
|
11686
11687
|
});
|
|
@@ -12444,14 +12445,14 @@ var init_hash_object = __esm({
|
|
|
12444
12445
|
init_task();
|
|
12445
12446
|
}
|
|
12446
12447
|
});
|
|
12447
|
-
function parseInit(bare,
|
|
12448
|
+
function parseInit(bare, path8, text) {
|
|
12448
12449
|
const response = String(text).trim();
|
|
12449
12450
|
let result;
|
|
12450
12451
|
if (result = initResponseRegex.exec(response)) {
|
|
12451
|
-
return new InitSummary(bare,
|
|
12452
|
+
return new InitSummary(bare, path8, false, result[1]);
|
|
12452
12453
|
}
|
|
12453
12454
|
if (result = reInitResponseRegex.exec(response)) {
|
|
12454
|
-
return new InitSummary(bare,
|
|
12455
|
+
return new InitSummary(bare, path8, true, result[1]);
|
|
12455
12456
|
}
|
|
12456
12457
|
let gitDir = "";
|
|
12457
12458
|
const tokens = response.split(" ");
|
|
@@ -12462,7 +12463,7 @@ function parseInit(bare, path7, text) {
|
|
|
12462
12463
|
break;
|
|
12463
12464
|
}
|
|
12464
12465
|
}
|
|
12465
|
-
return new InitSummary(bare,
|
|
12466
|
+
return new InitSummary(bare, path8, /^re/i.test(response), gitDir);
|
|
12466
12467
|
}
|
|
12467
12468
|
var InitSummary;
|
|
12468
12469
|
var initResponseRegex;
|
|
@@ -12471,9 +12472,9 @@ var init_InitSummary = __esm({
|
|
|
12471
12472
|
"src/lib/responses/InitSummary.ts"() {
|
|
12472
12473
|
"use strict";
|
|
12473
12474
|
InitSummary = class {
|
|
12474
|
-
constructor(bare,
|
|
12475
|
+
constructor(bare, path8, existing, gitDir) {
|
|
12475
12476
|
this.bare = bare;
|
|
12476
|
-
this.path =
|
|
12477
|
+
this.path = path8;
|
|
12477
12478
|
this.existing = existing;
|
|
12478
12479
|
this.gitDir = gitDir;
|
|
12479
12480
|
}
|
|
@@ -12485,7 +12486,7 @@ var init_InitSummary = __esm({
|
|
|
12485
12486
|
function hasBareCommand(command) {
|
|
12486
12487
|
return command.includes(bareCommand);
|
|
12487
12488
|
}
|
|
12488
|
-
function initTask(bare = false,
|
|
12489
|
+
function initTask(bare = false, path8, customArgs) {
|
|
12489
12490
|
const commands = ["init", ...customArgs];
|
|
12490
12491
|
if (bare && !hasBareCommand(commands)) {
|
|
12491
12492
|
commands.splice(1, 0, bareCommand);
|
|
@@ -12494,7 +12495,7 @@ function initTask(bare = false, path7, customArgs) {
|
|
|
12494
12495
|
commands,
|
|
12495
12496
|
format: "utf-8",
|
|
12496
12497
|
parser(text) {
|
|
12497
|
-
return parseInit(commands.includes("--bare"),
|
|
12498
|
+
return parseInit(commands.includes("--bare"), path8, text);
|
|
12498
12499
|
}
|
|
12499
12500
|
};
|
|
12500
12501
|
}
|
|
@@ -13309,12 +13310,12 @@ var init_FileStatusSummary = __esm({
|
|
|
13309
13310
|
"use strict";
|
|
13310
13311
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
13311
13312
|
FileStatusSummary = class {
|
|
13312
|
-
constructor(
|
|
13313
|
-
this.path =
|
|
13313
|
+
constructor(path8, index, working_dir) {
|
|
13314
|
+
this.path = path8;
|
|
13314
13315
|
this.index = index;
|
|
13315
13316
|
this.working_dir = working_dir;
|
|
13316
13317
|
if (index === "R" || working_dir === "R") {
|
|
13317
|
-
const detail = fromPathRegex.exec(
|
|
13318
|
+
const detail = fromPathRegex.exec(path8) || [null, path8, path8];
|
|
13318
13319
|
this.from = detail[2] || "";
|
|
13319
13320
|
this.path = detail[1] || "";
|
|
13320
13321
|
}
|
|
@@ -13345,14 +13346,14 @@ function splitLine(result, lineStr) {
|
|
|
13345
13346
|
default:
|
|
13346
13347
|
return;
|
|
13347
13348
|
}
|
|
13348
|
-
function data(index, workingDir,
|
|
13349
|
+
function data(index, workingDir, path8) {
|
|
13349
13350
|
const raw = `${index}${workingDir}`;
|
|
13350
13351
|
const handler = parsers6.get(raw);
|
|
13351
13352
|
if (handler) {
|
|
13352
|
-
handler(result,
|
|
13353
|
+
handler(result, path8);
|
|
13353
13354
|
}
|
|
13354
13355
|
if (raw !== "##" && raw !== "!!") {
|
|
13355
|
-
result.files.push(new FileStatusSummary(
|
|
13356
|
+
result.files.push(new FileStatusSummary(path8, index, workingDir));
|
|
13356
13357
|
}
|
|
13357
13358
|
}
|
|
13358
13359
|
}
|
|
@@ -13703,9 +13704,9 @@ var init_simple_git_api = __esm({
|
|
|
13703
13704
|
next
|
|
13704
13705
|
);
|
|
13705
13706
|
}
|
|
13706
|
-
hashObject(
|
|
13707
|
+
hashObject(path8, write) {
|
|
13707
13708
|
return this._runTask(
|
|
13708
|
-
hashObjectTask(
|
|
13709
|
+
hashObjectTask(path8, write === true),
|
|
13709
13710
|
trailingFunctionArgument(arguments)
|
|
13710
13711
|
);
|
|
13711
13712
|
}
|
|
@@ -14059,8 +14060,8 @@ var init_branch = __esm({
|
|
|
14059
14060
|
}
|
|
14060
14061
|
});
|
|
14061
14062
|
function toPath(input) {
|
|
14062
|
-
const
|
|
14063
|
-
return
|
|
14063
|
+
const path8 = input.trim().replace(/^["']|["']$/g, "");
|
|
14064
|
+
return path8 && (0, import_node_path.normalize)(path8);
|
|
14064
14065
|
}
|
|
14065
14066
|
var parseCheckIgnore;
|
|
14066
14067
|
var init_CheckIgnore = __esm({
|
|
@@ -14345,8 +14346,8 @@ __export2(sub_module_exports, {
|
|
|
14345
14346
|
subModuleTask: () => subModuleTask,
|
|
14346
14347
|
updateSubModuleTask: () => updateSubModuleTask
|
|
14347
14348
|
});
|
|
14348
|
-
function addSubModuleTask(repo,
|
|
14349
|
-
return subModuleTask(["add", repo,
|
|
14349
|
+
function addSubModuleTask(repo, path8) {
|
|
14350
|
+
return subModuleTask(["add", repo, path8]);
|
|
14350
14351
|
}
|
|
14351
14352
|
function initSubModuleTask(customArgs) {
|
|
14352
14353
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -14660,8 +14661,8 @@ var require_git = __commonJS2({
|
|
|
14660
14661
|
}
|
|
14661
14662
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
14662
14663
|
};
|
|
14663
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
14664
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
14664
|
+
Git2.prototype.submoduleAdd = function(repo, path8, then) {
|
|
14665
|
+
return this._runTask(addSubModuleTask2(repo, path8), trailingFunctionArgument2(arguments));
|
|
14665
14666
|
};
|
|
14666
14667
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
14667
14668
|
return this._runTask(
|
|
@@ -16418,7 +16419,7 @@ async function generateReceipt(options = {}) {
|
|
|
16418
16419
|
|
|
16419
16420
|
// src/index.ts
|
|
16420
16421
|
var program2 = new Command();
|
|
16421
|
-
program2.name("qodewk").description("Universal telemetry and digital receipt generator for the AI coding agent era").version("0.1
|
|
16422
|
+
program2.name("qodewk").description("Universal telemetry and digital receipt generator for the AI coding agent era").version("0.2.1").option("-j, --json", "Output receipt in machine-readable JSON format").option("-f, --format <format>", "Output format (terminal, json, markdown)", "terminal").option("-o, --out <path>", "Write receipt output to specified file path").option("-p, --provider <provider>", "Specify AI provider (antigravity, claude, cursor, etc.)").option("-m, --model <model>", "Specify AI model identifier").option("-s, --since <duration>", "Harvest agent footprints since duration (e.g. today, 24h, 7d)").option("--today", "Harvest agent footprints for today").option("--platform <platform>", "Filter agent platform (antigravity, claude, cursor, all)").option("--anon", "Anonymize branch name in output").option("--barcode", "Render 1D barcode simulation instead of scannable 2D QR code").action(async (options) => {
|
|
16422
16423
|
try {
|
|
16423
16424
|
const since = options.today ? "today" : options.since;
|
|
16424
16425
|
const receipt = await generateReceipt({
|
|
@@ -16466,7 +16467,7 @@ program2.command("share").description("Publish privacy-safe receipt to Qodewk cl
|
|
|
16466
16467
|
await renderTerminalReceipt(receipt, void 0, options.barcode);
|
|
16467
16468
|
return;
|
|
16468
16469
|
}
|
|
16469
|
-
const endpoint = process.env.QODEWK_API_URL || "https://qodewk.flinkeo.online/api/receipts
|
|
16470
|
+
const endpoint = process.env.QODEWK_API_URL || `${process.env.NEXT_PUBLIC_APP_URL || process.env.QODEWK_APP_URL || "https://qodewk.flinkeo.online"}/api/receipts`;
|
|
16470
16471
|
console.log(import_picocolors.default.dim(`Publishing receipt ${receipt.receipt.id} to ${endpoint}...`));
|
|
16471
16472
|
try {
|
|
16472
16473
|
const response = await fetch(endpoint, {
|
|
@@ -16494,6 +16495,80 @@ Could not reach cloud API (${networkErr.message}). Rendered locally:`));
|
|
|
16494
16495
|
process.exit(1);
|
|
16495
16496
|
}
|
|
16496
16497
|
});
|
|
16498
|
+
program2.command("record").description("Silently record local telemetry receipt into SQLite (used by git hooks)").action(async () => {
|
|
16499
|
+
try {
|
|
16500
|
+
const receipt = await generateReceipt();
|
|
16501
|
+
const db = new LocalStateDB();
|
|
16502
|
+
db.saveReceipt(receipt);
|
|
16503
|
+
db.close();
|
|
16504
|
+
process.exit(0);
|
|
16505
|
+
} catch {
|
|
16506
|
+
process.exit(0);
|
|
16507
|
+
}
|
|
16508
|
+
});
|
|
16509
|
+
var hookCommand = program2.command("hook").description("Manage non-blocking Git hooks for automatic telemetry recording");
|
|
16510
|
+
hookCommand.command("install").description("Install non-blocking post-commit Git hook into current repository").action(async () => {
|
|
16511
|
+
try {
|
|
16512
|
+
const gitDir = path7.join(process.cwd(), ".git");
|
|
16513
|
+
if (!fs6.existsSync(gitDir)) {
|
|
16514
|
+
console.error(import_picocolors.default.red("Error: Current directory is not a Git repository root (.git not found)."));
|
|
16515
|
+
process.exit(1);
|
|
16516
|
+
}
|
|
16517
|
+
const hooksDir = path7.join(gitDir, "hooks");
|
|
16518
|
+
if (!fs6.existsSync(hooksDir)) {
|
|
16519
|
+
fs6.mkdirSync(hooksDir, { recursive: true });
|
|
16520
|
+
}
|
|
16521
|
+
const hookFile = path7.join(hooksDir, "post-commit");
|
|
16522
|
+
const hookMarkerBegin = "# --- BEGIN QODEWK HOOK ---";
|
|
16523
|
+
const hookMarkerEnd = "# --- END QODEWK HOOK ---";
|
|
16524
|
+
const hookSnippet = `
|
|
16525
|
+
${hookMarkerBegin}
|
|
16526
|
+
# Non-blocking Qodewk background recorder (< 5ms)
|
|
16527
|
+
if command -v qodewk >/dev/null 2>&1 || command -v pnpm >/dev/null 2>&1 || [ -f "./node_modules/.bin/qodewk" ]; then
|
|
16528
|
+
( ( qodewk record || pnpm qodewk record || npx qodewk record ) >/dev/null 2>&1 & )
|
|
16529
|
+
fi
|
|
16530
|
+
${hookMarkerEnd}
|
|
16531
|
+
`;
|
|
16532
|
+
let content = "";
|
|
16533
|
+
if (fs6.existsSync(hookFile)) {
|
|
16534
|
+
content = fs6.readFileSync(hookFile, "utf-8");
|
|
16535
|
+
} else {
|
|
16536
|
+
content = "#!/bin/sh\n";
|
|
16537
|
+
}
|
|
16538
|
+
if (content.includes(hookMarkerBegin)) {
|
|
16539
|
+
console.log(import_picocolors.default.yellow("Qodewk post-commit hook is already installed."));
|
|
16540
|
+
return;
|
|
16541
|
+
}
|
|
16542
|
+
fs6.writeFileSync(hookFile, content + hookSnippet, { mode: 493 });
|
|
16543
|
+
console.log(import_picocolors.default.green("\u2713 Non-blocking Qodewk post-commit hook successfully installed in .git/hooks/post-commit"));
|
|
16544
|
+
} catch (err) {
|
|
16545
|
+
console.error(import_picocolors.default.red(`Failed to install Git hook: ${err.message}`));
|
|
16546
|
+
process.exit(1);
|
|
16547
|
+
}
|
|
16548
|
+
});
|
|
16549
|
+
hookCommand.command("uninstall").description("Remove Qodewk post-commit Git hook").action(async () => {
|
|
16550
|
+
try {
|
|
16551
|
+
const hookFile = path7.join(process.cwd(), ".git", "hooks", "post-commit");
|
|
16552
|
+
if (!fs6.existsSync(hookFile)) {
|
|
16553
|
+
console.log(import_picocolors.default.yellow("No post-commit hook found."));
|
|
16554
|
+
return;
|
|
16555
|
+
}
|
|
16556
|
+
const content = fs6.readFileSync(hookFile, "utf-8");
|
|
16557
|
+
const hookMarkerBegin = "# --- BEGIN QODEWK HOOK ---";
|
|
16558
|
+
const hookMarkerEnd = "# --- END QODEWK HOOK ---";
|
|
16559
|
+
if (!content.includes(hookMarkerBegin)) {
|
|
16560
|
+
console.log(import_picocolors.default.yellow("Qodewk hook is not installed."));
|
|
16561
|
+
return;
|
|
16562
|
+
}
|
|
16563
|
+
const regex = new RegExp(`\\n?${hookMarkerBegin}[\\s\\S]*?${hookMarkerEnd}\\n?`, "g");
|
|
16564
|
+
const updated = content.replace(regex, "");
|
|
16565
|
+
fs6.writeFileSync(hookFile, updated, { mode: 493 });
|
|
16566
|
+
console.log(import_picocolors.default.green("\u2713 Qodewk post-commit hook removed."));
|
|
16567
|
+
} catch (err) {
|
|
16568
|
+
console.error(import_picocolors.default.red(`Failed to uninstall hook: ${err.message}`));
|
|
16569
|
+
process.exit(1);
|
|
16570
|
+
}
|
|
16571
|
+
});
|
|
16497
16572
|
var ansiHex = (hexColor) => {
|
|
16498
16573
|
const num = parseInt(hexColor.replace("#", ""), 16);
|
|
16499
16574
|
const r2 = num >> 16 & 255;
|
|
@@ -16611,6 +16686,7 @@ async function renderTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16611
16686
|
printDivider("=");
|
|
16612
16687
|
printRow("");
|
|
16613
16688
|
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || process.env.QODEWK_APP_URL || "https://qodewk.flinkeo.online";
|
|
16689
|
+
const isPublished = Boolean(publicUrl);
|
|
16614
16690
|
const urlToDisplay = publicUrl || `${baseUrl}/r/${receipt.receipt.id}`;
|
|
16615
16691
|
const displayHost = baseUrl.replace(/^https?:\/\//, "");
|
|
16616
16692
|
if (useBarcode) {
|
|
@@ -16625,7 +16701,7 @@ async function renderTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16625
16701
|
} else {
|
|
16626
16702
|
const qrRows = renderTerminalQr(urlToDisplay);
|
|
16627
16703
|
if (qrRows.length > 0) {
|
|
16628
|
-
printCenteredRow(import_picocolors.default.dim("--- SCAN
|
|
16704
|
+
printCenteredRow(import_picocolors.default.dim(isPublished ? "--- SCAN PUBLIC RECEIPT ---" : "--- LOCAL PROOF OF WORK ---"));
|
|
16629
16705
|
printRow("");
|
|
16630
16706
|
for (const qrRow of qrRows) {
|
|
16631
16707
|
printCenteredRow(qrRow);
|
|
@@ -16635,8 +16711,12 @@ async function renderTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16635
16711
|
printCenteredRow(import_picocolors.default.bold("||| | ||||| ||| |||| |||||| |||| ||| ||||||| |||"));
|
|
16636
16712
|
}
|
|
16637
16713
|
}
|
|
16638
|
-
|
|
16639
|
-
|
|
16714
|
+
if (isPublished) {
|
|
16715
|
+
printCenteredRow(import_picocolors.default.cyan(displayHost));
|
|
16716
|
+
printCenteredRow(import_picocolors.default.underline(import_picocolors.default.cyan(`r/${receipt.receipt.id}`)));
|
|
16717
|
+
} else {
|
|
16718
|
+
printCenteredRow(import_picocolors.default.yellow("[ LOCAL RECORD \u2014 NOT PUBLISHED ]"));
|
|
16719
|
+
}
|
|
16640
16720
|
printRow("");
|
|
16641
16721
|
if (process.env.QODEWK_TELEMETRY === "off") {
|
|
16642
16722
|
printRow(` ${teal("[\u2713]")} QODEWK_TELEMETRY=off (Cloud sync disabled)`);
|
|
@@ -16644,9 +16724,14 @@ async function renderTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16644
16724
|
printRow(` ${green("[\u2713]")} Source code was never uploaded to Qodewk`);
|
|
16645
16725
|
console.log(" " + import_picocolors.default.bold(coral("\\/".repeat(28))));
|
|
16646
16726
|
console.log("");
|
|
16647
|
-
|
|
16727
|
+
if (isPublished) {
|
|
16728
|
+
console.log(` ${import_picocolors.default.dim("\u{1F517} Public Receipt:")} ${import_picocolors.default.underline(import_picocolors.default.cyan(urlToDisplay))}`);
|
|
16729
|
+
} else {
|
|
16730
|
+
console.log(` ${import_picocolors.default.dim("\u{1F4BE} Saved to local DB:")} ${import_picocolors.default.dim("~/.qodewk/state.db")}`);
|
|
16731
|
+
console.log(` ${import_picocolors.default.dim("\u{1F4A1} To publish & get shareable URL:")} ${import_picocolors.default.cyan("qodewk share")}`);
|
|
16732
|
+
}
|
|
16648
16733
|
if (!useBarcode) {
|
|
16649
|
-
console.log(` ${import_picocolors.default.dim("\u{1F4CA} View classic 1D barcode:")} ${import_picocolors.default.cyan("
|
|
16734
|
+
console.log(` ${import_picocolors.default.dim("\u{1F4CA} View classic 1D barcode:")} ${import_picocolors.default.cyan("qodewk --barcode")}`);
|
|
16650
16735
|
}
|
|
16651
16736
|
console.log("");
|
|
16652
16737
|
}
|