@metasession.co/devaudit-cli 0.3.11 → 0.3.12

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.js CHANGED
@@ -56,7 +56,7 @@ function emitJsonResult(payload) {
56
56
 
57
57
  // package.json
58
58
  var package_default = {
59
- version: "0.3.11"};
59
+ version: "0.3.12"};
60
60
 
61
61
  // src/lib/version.ts
62
62
  var CLI_VERSION = package_default.version;
@@ -685,12 +685,16 @@ async function createUploadSource(file) {
685
685
  }
686
686
  }
687
687
  function buildUploadForm(file, source, opts) {
688
+ const metadata = {
689
+ ...opts.metadata ?? {},
690
+ ...opts.commitTimestamp ? { commitTimestamp: opts.commitTimestamp } : {}
691
+ };
688
692
  const form = new FormData();
689
693
  form.set("file", source.blob, basename(file));
690
694
  form.set("projectSlug", opts.projectSlug);
691
695
  form.set("requirementId", opts.requirementId);
692
696
  form.set("evidenceType", opts.evidenceType);
693
- form.set("metadata", JSON.stringify(opts.metadata ?? {}));
697
+ form.set("metadata", JSON.stringify(metadata));
694
698
  if (opts.releaseVersion) form.set("releaseVersion", opts.releaseVersion);
695
699
  if (opts.createReleaseIfMissing) form.set("createReleaseIfMissing", "true");
696
700
  if (opts.environment) form.set("environment", opts.environment);
@@ -702,6 +706,8 @@ function buildUploadForm(file, source, opts) {
702
706
  if (opts.gateStatus) form.set("gateStatus", opts.gateStatus);
703
707
  if (opts.sdlcStage) form.set("sdlcStage", opts.sdlcStage);
704
708
  if (opts.testCycleId) form.set("testCycleId", opts.testCycleId);
709
+ if (opts.sentinelContent) form.set("sentinelContent", opts.sentinelContent);
710
+ if (opts.commitTimestamp) form.set("commitTimestamp", opts.commitTimestamp);
705
711
  return form;
706
712
  }
707
713
  function uploadFailureMessage(err, timeoutSeconds) {
@@ -786,7 +792,10 @@ async function uploadPresigned(file, source, opts) {
786
792
  const maxAttemptsPresigned = DEFAULT_PRESIGNED_MAX_ATTEMPTS;
787
793
  const timeoutSeconds = uploadMaxTimeSeconds();
788
794
  const presignedTimeoutSeconds = DEFAULT_PRESIGNED_UPLOAD_MAX_TIME_SECONDS;
789
- const metadata = opts.metadata ?? {};
795
+ const metadata = {
796
+ ...opts.metadata ?? {},
797
+ ...opts.commitTimestamp ? { commitTimestamp: opts.commitTimestamp } : {}
798
+ };
790
799
  let uploadUrl = "";
791
800
  let evidenceId = "";
792
801
  let attempt = 1;
@@ -817,8 +826,11 @@ async function uploadPresigned(file, source, opts) {
817
826
  ...opts.evidenceCategory ? { evidenceCategory: opts.evidenceCategory } : {},
818
827
  ...opts.releaseTitle ? { releaseTitle: opts.releaseTitle } : {},
819
828
  ...opts.releaseSummary ? { releaseSummary: opts.releaseSummary } : {},
829
+ ...opts.changeType ? { changeType: opts.changeType } : {},
820
830
  ...opts.sdlcStage ? { sdlcStage: opts.sdlcStage } : {},
821
- ...opts.testCycleId ? { testCycleId: opts.testCycleId } : {}
831
+ ...opts.testCycleId ? { testCycleId: opts.testCycleId } : {},
832
+ ...opts.sentinelContent ? { sentinelContent: opts.sentinelContent } : {},
833
+ ...opts.commitTimestamp ? { commitTimestamp: opts.commitTimestamp } : {}
822
834
  }),
823
835
  signal: controller.signal
824
836
  });
@@ -964,6 +976,7 @@ async function uploadEvidence(opts) {
964
976
 
965
977
  // src/commands/push.ts
966
978
  var DEFAULT_BASE_URL3 = "https://devaudit.metasession.co";
979
+ var TRACKED_CHANGE_TYPES = /* @__PURE__ */ new Set(["feat", "fix", "refactor", "perf", "compliance", "revert"]);
967
980
  function buildMetadata(options) {
968
981
  const metadata = {};
969
982
  if (options.gitSha) metadata["gitSha"] = options.gitSha;
@@ -975,6 +988,28 @@ function buildMetadata(options) {
975
988
  }
976
989
  return metadata;
977
990
  }
991
+ async function resolveSentinelContext(options) {
992
+ if (!options.changeType || !TRACKED_CHANGE_TYPES.has(options.changeType)) {
993
+ return {};
994
+ }
995
+ const sentinelPath = join(process.cwd(), ".sdlc-implementer-invoked");
996
+ let sentinelContent;
997
+ try {
998
+ const raw = await promises.readFile(sentinelPath, "utf8");
999
+ if (raw.trim()) sentinelContent = raw;
1000
+ } catch {
1001
+ sentinelContent = void 0;
1002
+ }
1003
+ let commitTimestamp;
1004
+ try {
1005
+ const target = options.gitSha?.trim() ? options.gitSha.trim() : "HEAD";
1006
+ const { stdout } = await execa("git", ["show", "-s", "--format=%cI", target], { reject: false });
1007
+ if (stdout.trim()) commitTimestamp = stdout.trim();
1008
+ } catch {
1009
+ commitTimestamp = void 0;
1010
+ }
1011
+ return { sentinelContent, commitTimestamp };
1012
+ }
978
1013
  function validateOptions(options) {
979
1014
  if (options.environment && !options.release) {
980
1015
  return "--environment requires --release (evidence without a release is orphaned)";
@@ -1045,6 +1080,8 @@ async function runPush(options) {
1045
1080
  await runHook(plugins, "beforePush", ctx);
1046
1081
  }
1047
1082
  const metadata = buildMetadata(options);
1083
+ const { sentinelContent, commitTimestamp } = await resolveSentinelContext(options);
1084
+ if (commitTimestamp) metadata["commitTimestamp"] = commitTimestamp;
1048
1085
  const results = await uploadEvidence({
1049
1086
  projectSlug: options.projectSlug,
1050
1087
  requirementId: options.requirementId,
@@ -1063,6 +1100,8 @@ async function runPush(options) {
1063
1100
  ...options.gateStatus !== void 0 ? { gateStatus: options.gateStatus } : {},
1064
1101
  ...options.sdlcStage !== void 0 ? { sdlcStage: options.sdlcStage } : {},
1065
1102
  ...options.testCycleId !== void 0 ? { testCycleId: options.testCycleId } : {},
1103
+ ...sentinelContent !== void 0 ? { sentinelContent } : {},
1104
+ ...commitTimestamp !== void 0 ? { commitTimestamp } : {},
1066
1105
  metadata
1067
1106
  });
1068
1107
  let okCount = 0;