@ascenda-one/github-collector 0.1.6 → 0.1.8
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/cli.js +239 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -65,6 +65,75 @@ var require_commandClassifier = __commonJS({
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
// ../packages/tool-kit/out/commandHeads.js
|
|
69
|
+
var require_commandHeads = __commonJS({
|
|
70
|
+
"../packages/tool-kit/out/commandHeads.js"(exports) {
|
|
71
|
+
"use strict";
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.commandHeads = commandHeads;
|
|
74
|
+
function commandHeads(value) {
|
|
75
|
+
const stripped = stripQuoted(stripHeredocBodies(value));
|
|
76
|
+
return stripped.split(/[;&|()\n]+/).map((segment) => {
|
|
77
|
+
let head = segment.trim();
|
|
78
|
+
for (; ; ) {
|
|
79
|
+
const env = /^[a-z_][a-z0-9_]*=\S*\s+/.exec(head);
|
|
80
|
+
if (!env)
|
|
81
|
+
break;
|
|
82
|
+
head = head.slice(env[0].length);
|
|
83
|
+
}
|
|
84
|
+
return head;
|
|
85
|
+
}).filter((head) => head.length > 0);
|
|
86
|
+
}
|
|
87
|
+
function stripHeredocBodies(value) {
|
|
88
|
+
const marker = /<<-?\s*(["']?)(\w+)\1/;
|
|
89
|
+
let kept = "";
|
|
90
|
+
let rest = value;
|
|
91
|
+
for (; ; ) {
|
|
92
|
+
const opened = marker.exec(rest);
|
|
93
|
+
if (!opened)
|
|
94
|
+
return kept + rest;
|
|
95
|
+
const introLineEnd = rest.indexOf("\n", opened.index + opened[0].length);
|
|
96
|
+
if (introLineEnd === -1)
|
|
97
|
+
return kept + rest;
|
|
98
|
+
kept += rest.slice(0, introLineEnd + 1);
|
|
99
|
+
const body = rest.slice(introLineEnd + 1);
|
|
100
|
+
const terminator = new RegExp(`^\\s*${opened[2]}\\s*$`, "m").exec(body);
|
|
101
|
+
if (!terminator)
|
|
102
|
+
return kept;
|
|
103
|
+
rest = body.slice(terminator.index + terminator[0].length);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function stripQuoted(value) {
|
|
107
|
+
let out = "";
|
|
108
|
+
let i = 0;
|
|
109
|
+
while (i < value.length) {
|
|
110
|
+
const ch = value[i];
|
|
111
|
+
if (ch === "'") {
|
|
112
|
+
const close = value.indexOf("'", i + 1);
|
|
113
|
+
if (close === -1)
|
|
114
|
+
return out;
|
|
115
|
+
i = close + 1;
|
|
116
|
+
} else if (ch === '"') {
|
|
117
|
+
let j = i + 1;
|
|
118
|
+
while (j < value.length && value[j] !== '"') {
|
|
119
|
+
j += value[j] === "\\" ? 2 : 1;
|
|
120
|
+
}
|
|
121
|
+
if (j >= value.length)
|
|
122
|
+
return out;
|
|
123
|
+
i = j + 1;
|
|
124
|
+
} else if (ch === "\\") {
|
|
125
|
+
out += value.slice(i, i + 2);
|
|
126
|
+
i += 2;
|
|
127
|
+
} else {
|
|
128
|
+
out += ch;
|
|
129
|
+
i += 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
68
137
|
// ../packages/tool-kit/out/gitActionClassifier.js
|
|
69
138
|
var require_gitActionClassifier = __commonJS({
|
|
70
139
|
"../packages/tool-kit/out/gitActionClassifier.js"(exports) {
|
|
@@ -72,25 +141,27 @@ var require_gitActionClassifier = __commonJS({
|
|
|
72
141
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
142
|
exports.classifyGitAction = classifyGitAction;
|
|
74
143
|
exports.isReworkGitAction = isReworkGitAction;
|
|
144
|
+
var commandHeads_1 = require_commandHeads();
|
|
75
145
|
function classifyGitAction(command) {
|
|
76
146
|
if (!command)
|
|
77
147
|
return void 0;
|
|
78
148
|
const value = command.toLowerCase().trim();
|
|
79
149
|
if (!/\bgit\b/.test(value))
|
|
80
150
|
return void 0;
|
|
81
|
-
|
|
151
|
+
const heads = (0, commandHeads_1.commandHeads)(value);
|
|
152
|
+
if (heads.some((h) => /^git\s+commit\b/.test(h) && /\s--amend\b/.test(h)))
|
|
82
153
|
return "amend";
|
|
83
|
-
if (
|
|
154
|
+
if (heads.some((h) => /^git\s+revert\b/.test(h)))
|
|
84
155
|
return "revert";
|
|
85
|
-
if (
|
|
156
|
+
if (heads.some((h) => /^git\s+reset\b/.test(h) && /\s--hard\b/.test(h)))
|
|
86
157
|
return "reset_hard";
|
|
87
|
-
if (
|
|
158
|
+
if (heads.some((h) => /^git\s+restore\b/.test(h) && !/\s--staged\b/.test(h)))
|
|
88
159
|
return "restore";
|
|
89
|
-
if (
|
|
160
|
+
if (heads.some((h) => /^git\s+checkout\b.*\s--\s/.test(h)))
|
|
90
161
|
return "restore";
|
|
91
|
-
if (
|
|
162
|
+
if (heads.some((h) => /^git\s+push\b/.test(h)))
|
|
92
163
|
return "push";
|
|
93
|
-
if (
|
|
164
|
+
if (heads.some((h) => /^git\s+commit\b/.test(h)))
|
|
94
165
|
return "commit";
|
|
95
166
|
return void 0;
|
|
96
167
|
}
|
|
@@ -107,17 +178,19 @@ var require_workMilestoneClassifier = __commonJS({
|
|
|
107
178
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
108
179
|
exports.classifyWorkMilestone = classifyWorkMilestone;
|
|
109
180
|
exports.invitesDebrief = invitesDebrief;
|
|
181
|
+
var commandHeads_1 = require_commandHeads();
|
|
110
182
|
function classifyWorkMilestone(command) {
|
|
111
183
|
if (!command)
|
|
112
184
|
return void 0;
|
|
113
185
|
const value = command.toLowerCase().trim();
|
|
114
186
|
if (!/\bgh\b/.test(value))
|
|
115
187
|
return void 0;
|
|
116
|
-
|
|
188
|
+
const heads = (0, commandHeads_1.commandHeads)(value);
|
|
189
|
+
if (heads.some((head) => /^gh\s+pr\s+merge\b/.test(head)))
|
|
117
190
|
return "pr_merged";
|
|
118
|
-
if (
|
|
191
|
+
if (heads.some((head) => /^gh\s+issue\s+close\b/.test(head)))
|
|
119
192
|
return "issue_closed";
|
|
120
|
-
if (
|
|
193
|
+
if (heads.some((head) => /^gh\s+pr\s+create\b/.test(head)))
|
|
121
194
|
return "pr_opened";
|
|
122
195
|
return void 0;
|
|
123
196
|
}
|
|
@@ -204,6 +277,7 @@ var require_payload = __commonJS({
|
|
|
204
277
|
exports.getNestedString = getNestedString;
|
|
205
278
|
exports.getNestedNumber = getNestedNumber;
|
|
206
279
|
exports.inferOutcome = inferOutcome;
|
|
280
|
+
exports.outcomeForHook = outcomeForHook;
|
|
207
281
|
exports.looksLikeCorrection = looksLikeCorrection;
|
|
208
282
|
function getString(input, keys) {
|
|
209
283
|
for (const key of keys) {
|
|
@@ -255,6 +329,18 @@ var require_payload = __commonJS({
|
|
|
255
329
|
return "failure";
|
|
256
330
|
return "unknown";
|
|
257
331
|
}
|
|
332
|
+
function outcomeForHook(hookName, input) {
|
|
333
|
+
if (hookName === "PostToolUseFailure") {
|
|
334
|
+
const interrupted = input["is_interrupt"] === true || getNested(input, ["tool_response", "interrupted"]) === true;
|
|
335
|
+
return interrupted ? "cancelled" : "failure";
|
|
336
|
+
}
|
|
337
|
+
if (hookName === "PostToolUse") {
|
|
338
|
+
if (getNested(input, ["tool_response", "interrupted"]) === true)
|
|
339
|
+
return "cancelled";
|
|
340
|
+
return "success";
|
|
341
|
+
}
|
|
342
|
+
return "unknown";
|
|
343
|
+
}
|
|
258
344
|
function looksLikeCorrection(text) {
|
|
259
345
|
if (!text)
|
|
260
346
|
return false;
|
|
@@ -713,12 +799,138 @@ var require_salt = __commonJS({
|
|
|
713
799
|
}
|
|
714
800
|
});
|
|
715
801
|
|
|
802
|
+
// ../packages/tool-kit/out/liveBus.js
|
|
803
|
+
var require_liveBus = __commonJS({
|
|
804
|
+
"../packages/tool-kit/out/liveBus.js"(exports) {
|
|
805
|
+
"use strict";
|
|
806
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
807
|
+
if (k2 === void 0) k2 = k;
|
|
808
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
809
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
810
|
+
desc = { enumerable: true, get: function() {
|
|
811
|
+
return m[k];
|
|
812
|
+
} };
|
|
813
|
+
}
|
|
814
|
+
Object.defineProperty(o, k2, desc);
|
|
815
|
+
} : function(o, m, k, k2) {
|
|
816
|
+
if (k2 === void 0) k2 = k;
|
|
817
|
+
o[k2] = m[k];
|
|
818
|
+
});
|
|
819
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
820
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
821
|
+
} : function(o, v) {
|
|
822
|
+
o["default"] = v;
|
|
823
|
+
});
|
|
824
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
825
|
+
var ownKeys = function(o) {
|
|
826
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
827
|
+
var ar = [];
|
|
828
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
829
|
+
return ar;
|
|
830
|
+
};
|
|
831
|
+
return ownKeys(o);
|
|
832
|
+
};
|
|
833
|
+
return function(mod) {
|
|
834
|
+
if (mod && mod.__esModule) return mod;
|
|
835
|
+
var result = {};
|
|
836
|
+
if (mod != null) {
|
|
837
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
838
|
+
}
|
|
839
|
+
__setModuleDefault(result, mod);
|
|
840
|
+
return result;
|
|
841
|
+
};
|
|
842
|
+
}();
|
|
843
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
844
|
+
exports.liveBusSocketCandidates = liveBusSocketCandidates;
|
|
845
|
+
exports.liveBusSocketPath = liveBusSocketPath;
|
|
846
|
+
exports.bucketPromptSize = bucketPromptSize;
|
|
847
|
+
exports.emitLiveSignal = emitLiveSignal;
|
|
848
|
+
var fs = __importStar(__require("fs"));
|
|
849
|
+
var net = __importStar(__require("net"));
|
|
850
|
+
var os = __importStar(__require("os"));
|
|
851
|
+
var path = __importStar(__require("path"));
|
|
852
|
+
var WRITE_TIMEOUT_MS = 50;
|
|
853
|
+
var APP_BUNDLE_ID = "one.ascenda.ascendaMissionControl";
|
|
854
|
+
function liveBusSocketCandidates() {
|
|
855
|
+
const override = process.env.ASCENDA_LIVE_BUS_SOCKET;
|
|
856
|
+
if (override)
|
|
857
|
+
return [override];
|
|
858
|
+
const home = os.homedir();
|
|
859
|
+
return [
|
|
860
|
+
path.join(home, ".ascenda", "live.sock"),
|
|
861
|
+
path.join(home, "Library", "Containers", APP_BUNDLE_ID, "Data", ".ascenda", "live.sock")
|
|
862
|
+
];
|
|
863
|
+
}
|
|
864
|
+
function liveBusSocketPath() {
|
|
865
|
+
const candidates = liveBusSocketCandidates();
|
|
866
|
+
for (const candidate of candidates) {
|
|
867
|
+
try {
|
|
868
|
+
if (fs.statSync(candidate).isSocket())
|
|
869
|
+
return candidate;
|
|
870
|
+
} catch {
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return candidates[0];
|
|
874
|
+
}
|
|
875
|
+
function bucketPromptSize(text) {
|
|
876
|
+
const length = typeof text === "string" ? text.length : 0;
|
|
877
|
+
if (length <= 280)
|
|
878
|
+
return "s";
|
|
879
|
+
if (length <= 2e3)
|
|
880
|
+
return "m";
|
|
881
|
+
if (length <= 8e3)
|
|
882
|
+
return "l";
|
|
883
|
+
return "xl";
|
|
884
|
+
}
|
|
885
|
+
function emitLiveSignal(signal) {
|
|
886
|
+
return new Promise((resolve) => {
|
|
887
|
+
let settled = false;
|
|
888
|
+
const done = () => {
|
|
889
|
+
if (settled)
|
|
890
|
+
return;
|
|
891
|
+
settled = true;
|
|
892
|
+
try {
|
|
893
|
+
socket.destroy();
|
|
894
|
+
} catch {
|
|
895
|
+
}
|
|
896
|
+
resolve();
|
|
897
|
+
};
|
|
898
|
+
let socket;
|
|
899
|
+
try {
|
|
900
|
+
socket = net.createConnection(liveBusSocketPath());
|
|
901
|
+
} catch {
|
|
902
|
+
resolve();
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
const timer = setTimeout(done, WRITE_TIMEOUT_MS);
|
|
906
|
+
if (typeof timer.unref === "function")
|
|
907
|
+
timer.unref();
|
|
908
|
+
if (typeof socket.unref === "function")
|
|
909
|
+
socket.unref();
|
|
910
|
+
socket.on("error", done);
|
|
911
|
+
socket.on("connect", () => {
|
|
912
|
+
try {
|
|
913
|
+
socket.write(`${JSON.stringify(signal)}
|
|
914
|
+
`, () => {
|
|
915
|
+
clearTimeout(timer);
|
|
916
|
+
done();
|
|
917
|
+
});
|
|
918
|
+
} catch {
|
|
919
|
+
clearTimeout(timer);
|
|
920
|
+
done();
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
|
|
716
928
|
// ../packages/tool-kit/out/index.js
|
|
717
929
|
var require_out2 = __commonJS({
|
|
718
930
|
"../packages/tool-kit/out/index.js"(exports) {
|
|
719
931
|
"use strict";
|
|
720
932
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
721
|
-
exports.parseIngestResponse = exports.postToolEventsBatch = exports.postToolEvent = exports.renewToolToken = exports.getPairingStatus = exports.createPairingSession = exports.AscendaApiError = exports.hashWithMachineSalt = exports.readOrCreateMachineSalt = exports.machineSaltFilePath = exports.readTokenFile = exports.persistEventWriteToken = exports.defaultTokenFilePath = exports.AscendaSemanticEventError = exports.AscendaEventSender = exports.looksLikeCorrection = exports.inferOutcome = exports.getNestedNumber = exports.getNestedString = exports.getNested = exports.getNumber = exports.getString = exports.isAfterHours = exports.bucketDurationMs = exports.bucketLinesChanged = exports.invitesDebrief = exports.classifyWorkMilestone = exports.isReworkGitAction = exports.classifyGitAction = exports.isVerificationCommand = exports.classifyCommand = void 0;
|
|
933
|
+
exports.parseIngestResponse = exports.postToolEventsBatch = exports.postToolEvent = exports.renewToolToken = exports.getPairingStatus = exports.createPairingSession = exports.AscendaApiError = exports.liveBusSocketCandidates = exports.liveBusSocketPath = exports.bucketPromptSize = exports.emitLiveSignal = exports.hashWithMachineSalt = exports.readOrCreateMachineSalt = exports.machineSaltFilePath = exports.readTokenFile = exports.persistEventWriteToken = exports.defaultTokenFilePath = exports.AscendaSemanticEventError = exports.AscendaEventSender = exports.looksLikeCorrection = exports.outcomeForHook = exports.inferOutcome = exports.getNestedNumber = exports.getNestedString = exports.getNested = exports.getNumber = exports.getString = exports.isAfterHours = exports.bucketDurationMs = exports.bucketLinesChanged = exports.invitesDebrief = exports.classifyWorkMilestone = exports.isReworkGitAction = exports.classifyGitAction = exports.isVerificationCommand = exports.classifyCommand = void 0;
|
|
722
934
|
var commandClassifier_1 = require_commandClassifier();
|
|
723
935
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
724
936
|
return commandClassifier_1.classifyCommand;
|
|
@@ -770,6 +982,9 @@ var require_out2 = __commonJS({
|
|
|
770
982
|
Object.defineProperty(exports, "inferOutcome", { enumerable: true, get: function() {
|
|
771
983
|
return payload_1.inferOutcome;
|
|
772
984
|
} });
|
|
985
|
+
Object.defineProperty(exports, "outcomeForHook", { enumerable: true, get: function() {
|
|
986
|
+
return payload_1.outcomeForHook;
|
|
987
|
+
} });
|
|
773
988
|
Object.defineProperty(exports, "looksLikeCorrection", { enumerable: true, get: function() {
|
|
774
989
|
return payload_1.looksLikeCorrection;
|
|
775
990
|
} });
|
|
@@ -800,6 +1015,19 @@ var require_out2 = __commonJS({
|
|
|
800
1015
|
Object.defineProperty(exports, "hashWithMachineSalt", { enumerable: true, get: function() {
|
|
801
1016
|
return salt_1.hashWithMachineSalt;
|
|
802
1017
|
} });
|
|
1018
|
+
var liveBus_1 = require_liveBus();
|
|
1019
|
+
Object.defineProperty(exports, "emitLiveSignal", { enumerable: true, get: function() {
|
|
1020
|
+
return liveBus_1.emitLiveSignal;
|
|
1021
|
+
} });
|
|
1022
|
+
Object.defineProperty(exports, "bucketPromptSize", { enumerable: true, get: function() {
|
|
1023
|
+
return liveBus_1.bucketPromptSize;
|
|
1024
|
+
} });
|
|
1025
|
+
Object.defineProperty(exports, "liveBusSocketPath", { enumerable: true, get: function() {
|
|
1026
|
+
return liveBus_1.liveBusSocketPath;
|
|
1027
|
+
} });
|
|
1028
|
+
Object.defineProperty(exports, "liveBusSocketCandidates", { enumerable: true, get: function() {
|
|
1029
|
+
return liveBus_1.liveBusSocketCandidates;
|
|
1030
|
+
} });
|
|
803
1031
|
var http_1 = require_http();
|
|
804
1032
|
Object.defineProperty(exports, "AscendaApiError", { enumerable: true, get: function() {
|
|
805
1033
|
return http_1.AscendaApiError;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"publishConfig": { "access": "public" },
|
|
3
3
|
"name": "@ascenda-one/github-collector",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"description": "Code-forge collaboration collector for Ascenda work telemetry — first-person review and pull-request signals.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|