@ascenda-one/github-collector 0.1.5 → 0.1.7
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 +100 -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;
|
|
@@ -718,7 +804,7 @@ var require_out2 = __commonJS({
|
|
|
718
804
|
"../packages/tool-kit/out/index.js"(exports) {
|
|
719
805
|
"use strict";
|
|
720
806
|
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;
|
|
807
|
+
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.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
808
|
var commandClassifier_1 = require_commandClassifier();
|
|
723
809
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
724
810
|
return commandClassifier_1.classifyCommand;
|
|
@@ -770,6 +856,9 @@ var require_out2 = __commonJS({
|
|
|
770
856
|
Object.defineProperty(exports, "inferOutcome", { enumerable: true, get: function() {
|
|
771
857
|
return payload_1.inferOutcome;
|
|
772
858
|
} });
|
|
859
|
+
Object.defineProperty(exports, "outcomeForHook", { enumerable: true, get: function() {
|
|
860
|
+
return payload_1.outcomeForHook;
|
|
861
|
+
} });
|
|
773
862
|
Object.defineProperty(exports, "looksLikeCorrection", { enumerable: true, get: function() {
|
|
774
863
|
return payload_1.looksLikeCorrection;
|
|
775
864
|
} });
|
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.7",
|
|
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",
|