@kaddo/cli 3.82.0 → 3.84.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.
package/dist/index.js CHANGED
@@ -17381,7 +17381,7 @@ async function runTopologyApply(file, opts = {}) {
17381
17381
 
17382
17382
  // src/services/integrations.ts
17383
17383
  import matter11 from "gray-matter";
17384
- import { parse as parseYaml17 } from "yaml";
17384
+ import { parse as parseYaml17, stringify as stringifyYaml8 } from "yaml";
17385
17385
 
17386
17386
  // src/core/work-item-write.ts
17387
17387
  import fs4 from "fs";
@@ -17636,6 +17636,71 @@ function parseCredentials(raw, id, findings) {
17636
17636
  }
17637
17637
  return creds;
17638
17638
  }
17639
+ function parseSecrets(raw, id, findings) {
17640
+ const secrets = {};
17641
+ if (raw == null) return secrets;
17642
+ if (typeof raw !== "object" || Array.isArray(raw)) {
17643
+ findings.push({ level: "blocking", id, message: `Integration "${id}": secrets must be a mapping of logical references.` });
17644
+ return secrets;
17645
+ }
17646
+ for (const [key, value] of Object.entries(raw)) {
17647
+ if (typeof value === "string" && value.trim()) {
17648
+ if (value.length > 100 || /^(ghp_|sk-|xox[bpsa]-|glpat-|ey[A-Za-z0-9])/i.test(value)) {
17649
+ findings.push({ level: "blocking", id, message: `Integration "${id}": secret "${key}" appears to contain an actual credential, not a reference name.` });
17650
+ continue;
17651
+ }
17652
+ secrets[key] = value.trim();
17653
+ } else {
17654
+ findings.push({ level: "warning", id, message: `Integration "${id}": ignoring non-string secret entry "${key}".` });
17655
+ }
17656
+ }
17657
+ return secrets;
17658
+ }
17659
+ function toStringArray4(raw) {
17660
+ if (raw == null) return void 0;
17661
+ if (Array.isArray(raw)) return raw.filter((v) => typeof v === "string" && v.trim() !== "").map((v) => v.trim());
17662
+ if (typeof raw === "string" && raw.trim()) return [raw.trim()];
17663
+ return void 0;
17664
+ }
17665
+ function parseFilters(raw) {
17666
+ if (raw == null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
17667
+ const o = raw;
17668
+ const filters = {};
17669
+ let hasAny = false;
17670
+ const types = toStringArray4(o.types);
17671
+ if (types?.length) {
17672
+ filters.types = types;
17673
+ hasAny = true;
17674
+ }
17675
+ const statuses = toStringArray4(o.statuses);
17676
+ if (statuses?.length) {
17677
+ filters.statuses = statuses;
17678
+ hasAny = true;
17679
+ }
17680
+ const labels = toStringArray4(o.labels);
17681
+ if (labels?.length) {
17682
+ filters.labels = labels;
17683
+ hasAny = true;
17684
+ }
17685
+ const assignees = toStringArray4(o.assignees);
17686
+ if (assignees?.length) {
17687
+ filters.assignees = assignees;
17688
+ hasAny = true;
17689
+ }
17690
+ if (typeof o.updatedAfter === "string" && o.updatedAfter.trim()) {
17691
+ filters.updatedAfter = o.updatedAfter.trim();
17692
+ hasAny = true;
17693
+ }
17694
+ if (typeof o.search === "string" && o.search.trim()) {
17695
+ filters.search = o.search.trim();
17696
+ hasAny = true;
17697
+ }
17698
+ if (typeof o.providerQuery === "string" && o.providerQuery.trim()) {
17699
+ filters.providerQuery = o.providerQuery.trim();
17700
+ hasAny = true;
17701
+ }
17702
+ return hasAny ? filters : void 0;
17703
+ }
17639
17704
  function parseIntegrationsConfig(raw, opts) {
17640
17705
  const findings = [];
17641
17706
  const integrations = [];
@@ -17668,12 +17733,14 @@ function parseIntegrationsConfig(raw, opts) {
17668
17733
  const enabled = o.enabled === void 0 ? true : o.enabled === true || o.enabled === "true";
17669
17734
  const config = o.config && typeof o.config === "object" && !Array.isArray(o.config) ? o.config : {};
17670
17735
  const credentials = parseCredentials(o.credentials, id, findings);
17736
+ const secrets = parseSecrets(o.secrets, id, findings);
17737
+ const filters = parseFilters(o.filters);
17671
17738
  const timeoutMs = typeof o.timeout_ms === "number" ? o.timeout_ms : typeof o.timeoutMs === "number" ? o.timeoutMs : void 0;
17672
- integrations.push({ id, adapter, enabled, config, credentials, timeoutMs });
17739
+ integrations.push({ id, adapter, enabled, config, credentials, secrets, filters, timeoutMs });
17673
17740
  }
17674
17741
  return { integrations, findings };
17675
17742
  }
17676
- function resolveCredentials(integration, env) {
17743
+ async function resolveAllCredentials(integration, resolver, env) {
17677
17744
  const credentials = {};
17678
17745
  const missing = [];
17679
17746
  for (const [name, ref] of Object.entries(integration.credentials)) {
@@ -17681,8 +17748,28 @@ function resolveCredentials(integration, env) {
17681
17748
  if (value && value.length > 0) credentials[name] = value;
17682
17749
  else missing.push(ref.env);
17683
17750
  }
17751
+ for (const [name, ref] of Object.entries(integration.secrets)) {
17752
+ if (credentials[name]) continue;
17753
+ const value = await resolver.resolve(ref);
17754
+ if (value !== void 0) credentials[name] = value;
17755
+ else missing.push(ref);
17756
+ }
17684
17757
  return { credentials, missing };
17685
17758
  }
17759
+ function mergeFilters(base, overlay) {
17760
+ if (!base && !overlay) return {};
17761
+ if (!base) return { ...overlay };
17762
+ if (!overlay) return { ...base };
17763
+ return {
17764
+ types: overlay.types?.length ? overlay.types : base.types,
17765
+ statuses: overlay.statuses?.length ? overlay.statuses : base.statuses,
17766
+ labels: overlay.labels?.length ? overlay.labels : base.labels,
17767
+ assignees: overlay.assignees?.length ? overlay.assignees : base.assignees,
17768
+ updatedAfter: overlay.updatedAfter ?? base.updatedAfter,
17769
+ search: overlay.search ?? base.search,
17770
+ providerQuery: overlay.providerQuery ?? base.providerQuery
17771
+ };
17772
+ }
17686
17773
 
17687
17774
  // ../integrations/src/preview.ts
17688
17775
  function buildImportPreview(item, opts) {
@@ -17705,6 +17792,82 @@ function buildImportPreview(item, opts) {
17705
17792
  };
17706
17793
  }
17707
17794
 
17795
+ // ../integrations/src/secrets.ts
17796
+ import { readFileSync as readFileSync2, writeFileSync, mkdirSync, existsSync as existsSync2, unlinkSync } from "fs";
17797
+ import { dirname as dirname2 } from "path";
17798
+ var SECRETS_FILENAME = ".secrets.json";
17799
+ function secretsPath(projectDir) {
17800
+ return `${projectDir}/.kaddo/${SECRETS_FILENAME}`;
17801
+ }
17802
+ function loadStore(filePath) {
17803
+ if (!existsSync2(filePath)) return {};
17804
+ try {
17805
+ const raw = readFileSync2(filePath, "utf-8");
17806
+ const parsed = JSON.parse(raw);
17807
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
17808
+ return {};
17809
+ } catch {
17810
+ return {};
17811
+ }
17812
+ }
17813
+ function saveStore(filePath, store) {
17814
+ mkdirSync(dirname2(filePath), { recursive: true });
17815
+ writeFileSync(filePath, JSON.stringify(store, null, 2) + "\n", "utf-8");
17816
+ }
17817
+ function createLocalSecretProvider(projectDir) {
17818
+ const fp = secretsPath(projectDir);
17819
+ return {
17820
+ async get(key) {
17821
+ const store = loadStore(fp);
17822
+ const val = store[key];
17823
+ return val !== void 0 && val !== "" ? val : void 0;
17824
+ },
17825
+ async set(key, value) {
17826
+ const store = loadStore(fp);
17827
+ store[key] = value;
17828
+ saveStore(fp, store);
17829
+ },
17830
+ async delete(key) {
17831
+ const store = loadStore(fp);
17832
+ delete store[key];
17833
+ saveStore(fp, store);
17834
+ },
17835
+ async exists(key) {
17836
+ const store = loadStore(fp);
17837
+ return key in store && store[key] !== void 0 && store[key] !== "";
17838
+ }
17839
+ };
17840
+ }
17841
+ function createEnvSecretProvider(env = process.env) {
17842
+ return {
17843
+ async get(key) {
17844
+ const val = env[key];
17845
+ return val !== void 0 && val !== "" ? val : void 0;
17846
+ },
17847
+ async set() {
17848
+ throw new Error("Environment secret provider is read-only.");
17849
+ },
17850
+ async delete() {
17851
+ throw new Error("Environment secret provider is read-only.");
17852
+ },
17853
+ async exists(key) {
17854
+ const val = env[key];
17855
+ return val !== void 0 && val !== "";
17856
+ }
17857
+ };
17858
+ }
17859
+ function createCompositeResolver(...providers) {
17860
+ return {
17861
+ async resolve(reference) {
17862
+ for (const provider of providers) {
17863
+ const val = await provider.get(reference);
17864
+ if (val !== void 0) return val;
17865
+ }
17866
+ return void 0;
17867
+ }
17868
+ };
17869
+ }
17870
+
17708
17871
  // ../integrations/src/registry.ts
17709
17872
  var DuplicateAdapterError = class extends Error {
17710
17873
  constructor(id) {
@@ -17744,6 +17907,7 @@ var DEFAULT_ITEMS = [
17744
17907
  status: "Open",
17745
17908
  url: "https://example.test/mock/EXT-001",
17746
17909
  labels: ["registration", "beta"],
17910
+ assignees: [{ name: "Alice" }],
17747
17911
  createdAt: "2026-01-05T10:00:00.000Z",
17748
17912
  updatedAt: "2026-02-01T09:30:00.000Z",
17749
17913
  rawMetadata: { board: "delivery" }
@@ -17757,8 +17921,86 @@ var DEFAULT_ITEMS = [
17757
17921
  status: "To Do",
17758
17922
  url: "https://example.test/mock/EXT-002",
17759
17923
  labels: ["onboarding"],
17924
+ assignees: [{ name: "Bob" }],
17760
17925
  createdAt: "2026-01-08T12:00:00.000Z",
17761
17926
  updatedAt: "2026-01-20T15:00:00.000Z"
17927
+ },
17928
+ {
17929
+ externalId: "EXT-003",
17930
+ provider: MOCK_ADAPTER_ID,
17931
+ title: "Fix authentication error on mobile",
17932
+ description: "Users on iOS 17 see a blank screen after OAuth redirect.",
17933
+ type: "Bug",
17934
+ status: "In Progress",
17935
+ url: "https://example.test/mock/EXT-003",
17936
+ labels: ["auth", "mobile", "critical"],
17937
+ assignees: [{ name: "Alice" }],
17938
+ createdAt: "2026-02-10T08:00:00.000Z",
17939
+ updatedAt: "2026-03-01T14:00:00.000Z"
17940
+ },
17941
+ {
17942
+ externalId: "EXT-004",
17943
+ provider: MOCK_ADAPTER_ID,
17944
+ title: "Design system token audit",
17945
+ description: "Review and consolidate design tokens across the component library.",
17946
+ type: "Task",
17947
+ status: "To Do",
17948
+ url: "https://example.test/mock/EXT-004",
17949
+ labels: ["frontend", "design-system"],
17950
+ createdAt: "2026-02-15T10:00:00.000Z",
17951
+ updatedAt: "2026-02-20T11:00:00.000Z"
17952
+ },
17953
+ {
17954
+ externalId: "EXT-005",
17955
+ provider: MOCK_ADAPTER_ID,
17956
+ title: "Migrate billing service to new payment gateway",
17957
+ description: "Stripe v2 migration \u2014 switch from legacy Charges API to Payment Intents.",
17958
+ type: "Epic",
17959
+ status: "Open",
17960
+ url: "https://example.test/mock/EXT-005",
17961
+ labels: ["billing", "backend", "migration"],
17962
+ assignees: [{ name: "Carol" }],
17963
+ createdAt: "2026-01-20T09:00:00.000Z",
17964
+ updatedAt: "2026-03-05T16:00:00.000Z"
17965
+ },
17966
+ {
17967
+ externalId: "EXT-006",
17968
+ provider: MOCK_ADAPTER_ID,
17969
+ title: "Add CSV export to reports",
17970
+ description: "Users need to export analytics reports as CSV for external tools.",
17971
+ type: "Feature",
17972
+ status: "In Progress",
17973
+ url: "https://example.test/mock/EXT-006",
17974
+ labels: ["reports", "backend"],
17975
+ assignees: [{ name: "Bob" }],
17976
+ createdAt: "2026-02-25T13:00:00.000Z",
17977
+ updatedAt: "2026-03-10T10:00:00.000Z"
17978
+ },
17979
+ {
17980
+ externalId: "EXT-007",
17981
+ provider: MOCK_ADAPTER_ID,
17982
+ title: "Improve search relevance scoring",
17983
+ description: "Tweak TF-IDF weights and add trigram matching for better search results.",
17984
+ type: "Task",
17985
+ status: "Done",
17986
+ url: "https://example.test/mock/EXT-007",
17987
+ labels: ["search", "backend"],
17988
+ assignees: [{ name: "Alice" }],
17989
+ createdAt: "2026-01-12T07:00:00.000Z",
17990
+ updatedAt: "2026-02-28T17:00:00.000Z"
17991
+ },
17992
+ {
17993
+ externalId: "EXT-008",
17994
+ provider: MOCK_ADAPTER_ID,
17995
+ title: "Set up E2E test pipeline",
17996
+ description: "Configure Playwright tests running on every PR via GitHub Actions.",
17997
+ type: "Task",
17998
+ status: "Done",
17999
+ url: "https://example.test/mock/EXT-008",
18000
+ labels: ["testing", "ci"],
18001
+ assignees: [{ name: "Carol" }],
18002
+ createdAt: "2026-01-30T11:00:00.000Z",
18003
+ updatedAt: "2026-02-15T09:00:00.000Z"
17762
18004
  }
17763
18005
  ];
17764
18006
  function simulationOf(context, fallback) {
@@ -17789,7 +18031,41 @@ function createMockAdapter(opts = {}) {
17789
18031
  id: MOCK_ADAPTER_ID,
17790
18032
  displayName: "Mock Work Source",
17791
18033
  version: "1.0.0",
17792
- description: "Deterministic offline reference adapter for validating the integration foundation."
18034
+ description: "Deterministic offline reference adapter for validating the integration foundation.",
18035
+ icon: "mock",
18036
+ filterCapabilities: {
18037
+ types: { supported: true, multiple: true },
18038
+ statuses: { supported: true, multiple: true },
18039
+ labels: { supported: true, multiple: true },
18040
+ assignees: { supported: true, multiple: true },
18041
+ updatedAfter: { supported: true },
18042
+ search: { supported: true },
18043
+ providerQuery: { supported: false }
18044
+ },
18045
+ configSchema: {
18046
+ simulate: {
18047
+ type: "select",
18048
+ required: false,
18049
+ label: "Simulation mode",
18050
+ description: "Controls what the mock adapter simulates during verify/read operations.",
18051
+ options: [
18052
+ { value: "available", label: "Available" },
18053
+ { value: "unauthorized", label: "Unauthorized" },
18054
+ { value: "rate-limited", label: "Rate Limited" },
18055
+ { value: "unavailable", label: "Unavailable" },
18056
+ { value: "timeout", label: "Timeout" }
18057
+ ],
18058
+ defaultValue: "available"
18059
+ }
18060
+ },
18061
+ secretSchema: {
18062
+ token: {
18063
+ type: "string",
18064
+ required: false,
18065
+ label: "API Token",
18066
+ description: "Optional token for testing secret handling (not used by the mock adapter)."
18067
+ }
18068
+ }
17793
18069
  },
17794
18070
  capabilities: {
17795
18071
  workItems: { list: true, read: true, import: true, write: false, statusSync: false, comments: false, webhooks: false }
@@ -17812,9 +18088,24 @@ function createMockAdapter(opts = {}) {
17812
18088
  readFailure(simulationOf(request.context, defaultSim));
17813
18089
  let pool = items;
17814
18090
  const f = request.filters;
17815
- if (f?.status) pool = pool.filter((i) => (i.status ?? "").toLowerCase() === f.status.toLowerCase());
17816
- if (f?.query) pool = pool.filter((i) => `${i.title} ${i.description ?? ""}`.toLowerCase().includes(f.query.toLowerCase()));
17817
- if (f?.updatedSince) pool = pool.filter((i) => (i.updatedAt ?? "") >= f.updatedSince);
18091
+ if (f?.statuses?.length) {
18092
+ const lower = f.statuses.map((s) => s.toLowerCase());
18093
+ pool = pool.filter((i) => lower.includes((i.status ?? "").toLowerCase()));
18094
+ }
18095
+ if (f?.types?.length) {
18096
+ const lower = f.types.map((t) => t.toLowerCase());
18097
+ pool = pool.filter((i) => lower.includes((i.type ?? "").toLowerCase()));
18098
+ }
18099
+ if (f?.labels?.length) {
18100
+ const lower = f.labels.map((l) => l.toLowerCase());
18101
+ pool = pool.filter((i) => i.labels?.some((il) => lower.includes(il.toLowerCase())));
18102
+ }
18103
+ if (f?.assignees?.length) {
18104
+ const lower = f.assignees.map((a) => a.toLowerCase());
18105
+ pool = pool.filter((i) => i.assignees?.some((a) => lower.includes((a.name ?? "").toLowerCase())));
18106
+ }
18107
+ if (f?.search) pool = pool.filter((i) => `${i.title} ${i.description ?? ""}`.toLowerCase().includes(f.search.toLowerCase()));
18108
+ if (f?.updatedAfter) pool = pool.filter((i) => (i.updatedAt ?? "") >= f.updatedAfter);
17818
18109
  const size = Math.max(1, request.pageSize ?? defaultPageSize);
17819
18110
  const start = request.cursor ? Math.max(0, Number.parseInt(request.cursor, 10) || 0) : 0;
17820
18111
  const slice = pool.slice(start, start + size);
@@ -17866,6 +18157,9 @@ function configStatus(integration, findings) {
17866
18157
  if (blocking || !registry.has(integration.adapter)) return "invalid-config";
17867
18158
  return "configured";
17868
18159
  }
18160
+ function secretResolver(dir, env) {
18161
+ return createCompositeResolver(createLocalSecretProvider(dir), createEnvSecretProvider(env));
18162
+ }
17869
18163
  function listIntegrations(dir) {
17870
18164
  const { integrations, findings } = loadIntegrations(dir);
17871
18165
  return integrations.map((integration) => {
@@ -17879,6 +18173,9 @@ function listIntegrations(dir) {
17879
18173
  capabilities: adapter?.capabilities ?? null,
17880
18174
  metadata: adapter?.metadata ?? null,
17881
18175
  credentialRefs: Object.values(integration.credentials).map((c) => c.env),
18176
+ secretRefs: Object.values(integration.secrets),
18177
+ secretStatus: {},
18178
+ filters: integration.filters,
17882
18179
  findings: findings.filter((f) => f.id === integration.id)
17883
18180
  };
17884
18181
  });
@@ -17887,15 +18184,16 @@ function requireIntegration(dir, id) {
17887
18184
  const { integrations, findings } = loadIntegrations(dir);
17888
18185
  const integration = integrations.find((i) => i.id === id);
17889
18186
  if (!integration) throw new IntegrationServiceError("INTEGRATION_NOT_CONFIGURED", `No integration "${id}" is configured in this project.`);
17890
- return { integration, findings };
18187
+ return { integration, findings, all: integrations };
17891
18188
  }
17892
18189
  function resolveAdapter(integration) {
17893
18190
  const adapter = registry.get(integration.adapter);
17894
18191
  if (!adapter) throw new IntegrationServiceError("ADAPTER_NOT_FOUND", `Unknown integration adapter "${integration.adapter}".`);
17895
18192
  return adapter;
17896
18193
  }
17897
- function buildContext(integration, env) {
17898
- const { credentials, missing } = resolveCredentials(integration, env);
18194
+ async function buildContextWithSecrets(dir, integration, env) {
18195
+ const resolver = secretResolver(dir, env);
18196
+ const { credentials, missing } = await resolveAllCredentials(integration, resolver, env);
17899
18197
  return {
17900
18198
  context: { integrationId: integration.id, config: integration.config, credentials, timeoutMs: integration.timeoutMs ?? DEFAULT_TIMEOUT_MS },
17901
18199
  missing
@@ -17918,7 +18216,7 @@ async function verifyIntegration(dir, id, env = process.env) {
17918
18216
  if (cfgStatus === "disabled") return { id, status: "disabled", connection: null, missingCredentials: [] };
17919
18217
  if (cfgStatus === "invalid-config") return { id, status: "invalid-config", connection: null, missingCredentials: [] };
17920
18218
  const adapter = resolveAdapter(integration);
17921
- const { context, missing } = buildContext(integration, env);
18219
+ const { context, missing } = await buildContextWithSecrets(dir, integration, env);
17922
18220
  try {
17923
18221
  const connection = await withTimeout(adapter.verifyConnection(context), context.timeoutMs);
17924
18222
  return { id, status: statusOf(connection), connection, missingCredentials: missing, message: connection.message };
@@ -17943,14 +18241,15 @@ async function listExternalWorkItems(dir, id, opts = {}, env = process.env) {
17943
18241
  const { integration } = requireIntegration(dir, id);
17944
18242
  const adapter = resolveAdapter(integration);
17945
18243
  if (!adapter.capabilities.workItems.list) throw integrationError("UNSUPPORTED_CAPABILITY", `Adapter "${adapter.id}" cannot list work items.`);
17946
- const { context } = buildContext(integration, env);
17947
- return withTimeout(adapter.listWorkItems({ context, cursor: opts.cursor, pageSize: opts.pageSize, filters: opts.filters }), context.timeoutMs);
18244
+ const { context } = await buildContextWithSecrets(dir, integration, env);
18245
+ const filters = mergeFilters(integration.filters, opts.filters);
18246
+ return withTimeout(adapter.listWorkItems({ context, cursor: opts.cursor, pageSize: opts.pageSize, filters }), context.timeoutMs);
17948
18247
  }
17949
18248
  async function getExternalWorkItem(dir, id, externalId, env = process.env) {
17950
18249
  const { integration } = requireIntegration(dir, id);
17951
18250
  const adapter = resolveAdapter(integration);
17952
18251
  if (!adapter.capabilities.workItems.read) throw integrationError("UNSUPPORTED_CAPABILITY", `Adapter "${adapter.id}" cannot read work items.`);
17953
- const { context } = buildContext(integration, env);
18252
+ const { context } = await buildContextWithSecrets(dir, integration, env);
17954
18253
  return withTimeout(adapter.getWorkItem({ context, externalId }), context.timeoutMs);
17955
18254
  }
17956
18255
  function findLinkedWorkItem(dir, integrationId, externalId) {
@@ -18069,10 +18368,13 @@ async function runIntegrationsVerify(dir, id, opts) {
18069
18368
  async function runIntegrationsWorkItems(dir, id, opts) {
18070
18369
  requireProject2(dir);
18071
18370
  try {
18371
+ const filters = {};
18372
+ if (opts.status) filters.statuses = [opts.status];
18373
+ if (opts.query) filters.search = opts.query;
18072
18374
  const page = await listExternalWorkItems(dir, id, {
18073
18375
  cursor: opts.cursor,
18074
18376
  pageSize: opts.pageSize ? Number.parseInt(opts.pageSize, 10) : void 0,
18075
- filters: { status: opts.status, query: opts.query }
18377
+ filters
18076
18378
  });
18077
18379
  if (opts.json) return printJson(page);
18078
18380
  intro2(`External work items \xB7 ${id}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaddo/cli",
3
- "version": "3.82.0",
3
+ "version": "3.84.0",
4
4
  "description": "Knowledge Driven Development toolkit",
5
5
  "license": "MIT",
6
6
  "repository": {