qodewk 0.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +153 -0
  3. package/package.json +55 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Qodewk Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js ADDED
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import * as fs from "fs";
5
+ import { Command } from "commander";
6
+ import pc from "picocolors";
7
+ import { generateReceipt, formatMarkdownReceipt, LocalStateDB } from "@qodewk/core";
8
+ var program = new Command();
9
+ program.name("qodewk").description("Universal telemetry and digital receipt generator for the AI coding agent era").version("0.1.0").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 (anthropic, openai, cursor, etc.)").option("-m, --model <model>", "Specify AI model identifier").option("--anon", "Anonymize branch name in output").action(async (options) => {
10
+ try {
11
+ const receipt = await generateReceipt({
12
+ provider: options.provider,
13
+ model: options.model,
14
+ anonymizeBranch: options.anon
15
+ });
16
+ try {
17
+ const db = new LocalStateDB();
18
+ db.saveReceipt(receipt);
19
+ db.close();
20
+ } catch {
21
+ }
22
+ outputReceipt(receipt, options);
23
+ } catch (err) {
24
+ console.error(pc.red(`Error generating receipt: ${err.message}`));
25
+ process.exit(1);
26
+ }
27
+ });
28
+ program.command("audit").description("Audit PR or branch diff against a target base commit").option("-b, --base <base>", "Base git ref or commit SHA (e.g. origin/main)").option("-h, --head <head>", "Head git ref or commit SHA").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").option("-m, --model <model>", "Specify AI model").action(async (options) => {
29
+ try {
30
+ const receipt = await generateReceipt({
31
+ baseSha: options.base,
32
+ headSha: options.head,
33
+ provider: options.provider,
34
+ model: options.model
35
+ });
36
+ outputReceipt(receipt, options);
37
+ } catch (err) {
38
+ console.error(pc.red(`Error auditing git range: ${err.message}`));
39
+ process.exit(1);
40
+ }
41
+ });
42
+ program.command("share").description("Publish privacy-safe receipt to Qodewk cloud and get a shareable URL").option("-p, --provider <provider>", "Specify AI provider").option("-m, --model <model>", "Specify AI model").action(async (options) => {
43
+ try {
44
+ const receipt = await generateReceipt({
45
+ provider: options.provider,
46
+ model: options.model
47
+ });
48
+ if (process.env.QODEWK_TELEMETRY === "off") {
49
+ console.log(pc.yellow("\n\u26A0\uFE0F Cloud publishing is disabled because QODEWK_TELEMETRY=off."));
50
+ console.log(pc.dim("Telemetry remains strictly stored in local SQLite (~/.qodewk/state.db).\n"));
51
+ renderTerminalReceipt(receipt);
52
+ return;
53
+ }
54
+ const endpoint = process.env.QODEWK_API_URL || "https://qodewk.dev/api/receipts";
55
+ console.log(pc.dim(`Publishing receipt ${receipt.receipt.id} to ${endpoint}...`));
56
+ try {
57
+ const response = await fetch(endpoint, {
58
+ method: "POST",
59
+ headers: {
60
+ "Content-Type": "application/json"
61
+ },
62
+ body: JSON.stringify(receipt)
63
+ });
64
+ if (!response.ok) {
65
+ throw new Error(`API responded with status ${response.status}`);
66
+ }
67
+ const data = await response.json();
68
+ const db = new LocalStateDB();
69
+ db.saveReceipt(receipt, data.claimToken);
70
+ db.close();
71
+ renderTerminalReceipt(receipt, data.url);
72
+ } catch (networkErr) {
73
+ console.log(pc.yellow(`
74
+ Could not reach cloud API (${networkErr.message}). Rendered locally:`));
75
+ renderTerminalReceipt(receipt);
76
+ }
77
+ } catch (err) {
78
+ console.error(pc.red(`Error sharing receipt: ${err.message}`));
79
+ process.exit(1);
80
+ }
81
+ });
82
+ var ansiHex = (hexColor) => {
83
+ const num = parseInt(hexColor.replace("#", ""), 16);
84
+ const r = num >> 16 & 255;
85
+ const g = num >> 8 & 255;
86
+ const b = num & 255;
87
+ return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
88
+ };
89
+ function outputReceipt(receipt, options, publicUrl) {
90
+ let content = "";
91
+ const format = options.json ? "json" : options.format || "terminal";
92
+ if (format === "json") {
93
+ content = JSON.stringify(receipt, null, 2);
94
+ } else if (format === "markdown") {
95
+ content = formatMarkdownReceipt(receipt, publicUrl);
96
+ }
97
+ if (options.out) {
98
+ fs.writeFileSync(options.out, content || formatMarkdownReceipt(receipt, publicUrl), "utf-8");
99
+ console.log(pc.green(`\u2713 Receipt written to ${options.out}`));
100
+ }
101
+ if (format === "terminal" && !options.out) {
102
+ renderTerminalReceipt(receipt, publicUrl);
103
+ } else if (format !== "terminal" && !options.out) {
104
+ console.log(content);
105
+ }
106
+ }
107
+ function renderTerminalReceipt(receipt, publicUrl) {
108
+ const coral = ansiHex("#cc785c");
109
+ const cream = ansiHex("#faf9f5");
110
+ const muted = ansiHex("#8e8b82");
111
+ const green = ansiHex("#5db872");
112
+ const teal = ansiHex("#5db8a6");
113
+ const totalTokens = (receipt.ai.tokens.input + receipt.ai.tokens.output).toLocaleString();
114
+ const inputK = `${Math.round(receipt.ai.tokens.input / 1e3)}k`;
115
+ const outputK = `${Math.round(receipt.ai.tokens.output / 1e3)}k`;
116
+ const costPrefix = receipt.ai.mode === "verified" ? "$" : "~$";
117
+ const confidencePercent = `${Math.round(receipt.ai.confidence * 100)}%`;
118
+ console.log("");
119
+ console.log(pc.bold(coral(" /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\")));
120
+ console.log(` | ${pc.bold(pc.white("Q O D E W K"))} |`);
121
+ console.log(` | ${coral("*** PROOF OF SHIPMENT ***")} |`);
122
+ console.log(" | |");
123
+ console.log(` | ID: ${receipt.receipt.id.slice(0, 24).padEnd(24)} DATE: ${receipt.receipt.createdAt.slice(0, 10)} |`);
124
+ console.log(` | REPO: ${receipt.repository.projectAlias.slice(0, 18).padEnd(18)} BRANCH: ${receipt.repository.branch.slice(0, 16).padEnd(16)} |`);
125
+ console.log(" | ==================================================== |");
126
+ console.log(" | ITEMS CHANGED QTY |");
127
+ console.log(" | ---------------------------------------------------- |");
128
+ console.log(` | Files Touched ${String(receipt.mutation.files).padStart(4)} |`);
129
+ console.log(` | Lines Inserted ${green(("+ " + receipt.mutation.insertions).padStart(6))} |`);
130
+ console.log(` | Lines Deleted ${pc.red(("- " + receipt.mutation.deletions).padStart(6))} |`);
131
+ console.log(` | Net Code Delta ${teal((receipt.mutation.netLines >= 0 ? "+ " : "- ") + Math.abs(receipt.mutation.netLines)).padStart(6)} |`);
132
+ console.log(" | ---------------------------------------------------- |");
133
+ console.log(" | AI TELEMETRY |");
134
+ console.log(` | Provider: ${(receipt.ai.provider + " \xB7 " + (receipt.ai.model || "Unknown")).slice(0, 36).padEnd(42)} |`);
135
+ console.log(` | Tokens: ${(inputK + " in (" + Math.round(receipt.ai.tokens.cached / 1e3) + "k cached) / " + outputK + " out").padEnd(42)} |`);
136
+ console.log(` | Total Tokens: ${totalTokens.padStart(38)} |`);
137
+ console.log(" | ==================================================== |");
138
+ console.log(` | ESTIMATED AI COST ${pc.bold(coral((costPrefix + receipt.ai.cost.toFixed(2)).padStart(8)))} |`);
139
+ console.log(` | CONFIDENCE: ${confidencePercent.padEnd(6)} [Mode: ${receipt.ai.mode.padEnd(9)}] |`);
140
+ console.log(" | ==================================================== |");
141
+ console.log(" | |");
142
+ console.log(` | ${pc.bold("||| | ||||| ||| |||| |||||| |||| ||| ||||||| |||")} |`);
143
+ const urlToDisplay = publicUrl || `https://qodewk.dev/r/${receipt.receipt.id}`;
144
+ console.log(` | ${pc.underline(pc.cyan(urlToDisplay.slice(0, 48))).padEnd(59)}|`);
145
+ console.log(" | |");
146
+ if (process.env.QODEWK_TELEMETRY === "off") {
147
+ console.log(` | ${teal("[\u2713]")} QODEWK_TELEMETRY=off (Cloud sync disabled) |`);
148
+ }
149
+ console.log(` | ${green("[\u2713]")} Source code was never uploaded to Qodewk |`);
150
+ console.log(pc.bold(coral(" \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/")));
151
+ console.log("");
152
+ }
153
+ program.parse(process.argv);
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "qodewk",
3
+ "version": "0.1.0",
4
+ "description": "Universal telemetry and digital receipt generator for the AI coding agent era",
5
+ "type": "module",
6
+ "bin": {
7
+ "qodewk": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "keywords": [
18
+ "ai",
19
+ "telemetry",
20
+ "git",
21
+ "receipt",
22
+ "claude",
23
+ "cursor",
24
+ "copilot",
25
+ "developer-receipt",
26
+ "llm-cost"
27
+ ],
28
+ "author": "Qodewk Contributors",
29
+ "license": "MIT",
30
+ "homepage": "https://qodewk.dev",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/abushaidislam/Qodewk.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/abushaidislam/Qodewk/issues"
37
+ },
38
+ "dependencies": {
39
+ "commander": "^13.1.0",
40
+ "picocolors": "^1.1.1",
41
+ "simple-git": "^3.27.0",
42
+ "@qodewk/pricing": "0.1.0",
43
+ "@qodewk/core": "0.1.0",
44
+ "@qodewk/protocol": "0.1.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^22.13.10",
48
+ "tsup": "^8.5.1",
49
+ "typescript": "^5.8.2"
50
+ },
51
+ "scripts": {
52
+ "build": "tsup",
53
+ "typecheck": "tsc --noEmit"
54
+ }
55
+ }