@kaddo/cli 3.108.0 → 3.109.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.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>admin</title>
8
- <script type="module" crossorigin src="/assets/index-CJ_ZkVBF.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-DmVDpmUe.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DNkI-1xG.css">
10
10
  </head>
11
11
  <body>
@@ -92,6 +92,16 @@ import {
92
92
  IntegrationError,
93
93
  IntegrationServiceError,
94
94
  WorkItemWriteError,
95
+ discoverInitiatives,
96
+ getInitiative as coreGetInitiative,
97
+ computeInitiativeProgress,
98
+ associatedWorkItems,
99
+ analyzeInitiative,
100
+ evaluateInitiativeCompletion,
101
+ createInitiative as coreCreateInitiative,
102
+ transitionInitiative as coreTransitionInitiative,
103
+ updateInitiative as coreUpdateInitiative,
104
+ InitiativeWriteError,
95
105
  exists,
96
106
  join,
97
107
  readFile
@@ -506,6 +516,89 @@ async function discoverExternalWorkItemsAdmin(dir, opts) {
506
516
  mapIntegrationError(err);
507
517
  }
508
518
  }
519
+ function assertValidInitiativeId(id) {
520
+ if (!id || id.includes("..") || id.includes("/") || id.includes("\\") || id.startsWith(".")) {
521
+ throw new CoreError("INVALID_INITIATIVE_ID", "Invalid Initiative identifier.");
522
+ }
523
+ }
524
+ function mapInitiativeError(err) {
525
+ if (err instanceof InitiativeWriteError) throw new CoreError("INITIATIVE_WRITE", err.message);
526
+ throw err;
527
+ }
528
+ function getInitiativesListAdmin(dir) {
529
+ const initiatives = discoverInitiatives(dir).map((ini) => {
530
+ const p = computeInitiativeProgress(dir, ini);
531
+ return {
532
+ id: ini.id,
533
+ title: ini.title,
534
+ status: ini.status,
535
+ horizon: ini.horizon,
536
+ priority: ini.priority,
537
+ planning: p.planning,
538
+ delivery: p.delivery
539
+ };
540
+ });
541
+ return { initiatives };
542
+ }
543
+ function getInitiativeDetailAdmin(dir, id) {
544
+ assertValidInitiativeId(id);
545
+ const ini = coreGetInitiative(dir, id);
546
+ if (!ini) throw new CoreError("INITIATIVE_NOT_FOUND", "This Initiative does not exist in the current project.");
547
+ return {
548
+ id: ini.id,
549
+ title: ini.title,
550
+ status: ini.status,
551
+ horizon: ini.horizon,
552
+ priority: ini.priority,
553
+ knowledgeLevel: ini.knowledgeLevel,
554
+ domains: ini.domains,
555
+ relatedCapabilities: ini.relatedCapabilities,
556
+ source: ini.source,
557
+ sourceId: ini.sourceId,
558
+ externalLinks: ini.externalLinks,
559
+ candidates: ini.candidates,
560
+ progress: computeInitiativeProgress(dir, ini),
561
+ workItems: associatedWorkItems(dir, ini.id),
562
+ analysis: analyzeInitiative(dir, ini),
563
+ completion: evaluateInitiativeCompletion(dir, ini),
564
+ body: ini.body
565
+ };
566
+ }
567
+ function createInitiativeAdmin(dir, body) {
568
+ try {
569
+ const ini = coreCreateInitiative(dir, {
570
+ title: body.title,
571
+ domains: body.domains,
572
+ horizon: body.horizon,
573
+ priority: body.priority
574
+ });
575
+ return { id: ini.id };
576
+ } catch (err) {
577
+ mapInitiativeError(err);
578
+ }
579
+ }
580
+ function updateInitiativeAdmin(dir, id, body) {
581
+ assertValidInitiativeId(id);
582
+ try {
583
+ let ini = coreGetInitiative(dir, id);
584
+ if (!ini) throw new CoreError("INITIATIVE_NOT_FOUND", "This Initiative does not exist in the current project.");
585
+ if (body.status) {
586
+ ini = coreTransitionInitiative(dir, id, body.status);
587
+ }
588
+ if (body.title !== void 0 || body.horizon !== void 0 || body.priority !== void 0 || body.domains !== void 0) {
589
+ ini = coreUpdateInitiative(dir, id, {
590
+ title: body.title,
591
+ horizon: body.horizon,
592
+ priority: body.priority,
593
+ domains: body.domains
594
+ });
595
+ }
596
+ return { id: ini.id, status: ini.status };
597
+ } catch (err) {
598
+ if (err instanceof CoreError) throw err;
599
+ mapInitiativeError(err);
600
+ }
601
+ }
509
602
  function getIntegrationFiltersAdmin(dir, id) {
510
603
  assertIntegrationId(id);
511
604
  try {
@@ -783,6 +876,19 @@ var WorkItemUpdateSchema = z.object({
783
876
  var WorkItemTransitionSchema = z.object({
784
877
  expectedRevision: z.string().min(1)
785
878
  });
879
+ var InitiativeCreateSchema = z.object({
880
+ title: z.string().min(1),
881
+ domains: z.array(z.string()).optional(),
882
+ horizon: z.string().optional(),
883
+ priority: z.string().optional()
884
+ });
885
+ var InitiativeUpdateSchema = z.object({
886
+ status: z.enum(["planned", "in-progress", "completed", "deferred", "cancelled"]).optional(),
887
+ title: z.string().min(1).optional(),
888
+ horizon: z.string().optional(),
889
+ priority: z.string().optional(),
890
+ domains: z.array(z.string()).optional()
891
+ });
786
892
  var WorkItemEditModelSchema = WorkItemInputSchema.extend({
787
893
  id: z.string(),
788
894
  status: z.string(),
@@ -883,8 +989,12 @@ function statusForCode(code) {
883
989
  case "INVALID_INTEGRATION_ID":
884
990
  case "INVALID_SECRET_NAME":
885
991
  case "INVALID_EXTERNAL_ID":
992
+ case "INVALID_INITIATIVE_ID":
993
+ case "INITIATIVE_WRITE":
886
994
  case "INVALID_TRANSITION":
887
995
  return 400;
996
+ case "INITIATIVE_NOT_FOUND":
997
+ return 404;
888
998
  default:
889
999
  return 500;
890
1000
  }
@@ -1021,6 +1131,20 @@ async function createAdminServer(opts) {
1021
1131
  throw err;
1022
1132
  }
1023
1133
  });
1134
+ app.get("/api/v1/admin/initiatives", coreRoute(getInitiativesListAdmin));
1135
+ app.post("/api/v1/admin/initiatives", async (request, reply) => {
1136
+ const parsed = InitiativeCreateSchema.safeParse(request.body);
1137
+ if (!parsed.success) return reply.code(400).send({ error: { code: "INVALID_INPUT", message: "A title is required." } });
1138
+ return writeHandler(reply, () => createInitiativeAdmin(projectDir, parsed.data));
1139
+ });
1140
+ app.get("/api/v1/admin/initiatives/:initiativeId", async (request, reply) => {
1141
+ return writeHandler(reply, () => getInitiativeDetailAdmin(projectDir, request.params.initiativeId));
1142
+ });
1143
+ app.put("/api/v1/admin/initiatives/:initiativeId", async (request, reply) => {
1144
+ const parsed = InitiativeUpdateSchema.safeParse(request.body);
1145
+ if (!parsed.success) return reply.code(400).send({ error: { code: "INVALID_INPUT", message: "Invalid initiative update." } });
1146
+ return writeHandler(reply, () => updateInitiativeAdmin(projectDir, request.params.initiativeId, parsed.data));
1147
+ });
1024
1148
  app.get("/api/v1/admin/modules", coreRoute(getModules));
1025
1149
  app.get("/api/v1/admin/readiness", coreRoute(getProjectReadiness));
1026
1150
  app.get("/api/v1/admin/route", coreRoute(getProjectRoute));
@@ -1313,6 +1437,8 @@ var SQLiteAdminStorage = class {
1313
1437
  export {
1314
1438
  ErrorResponseSchema,
1315
1439
  FindingsSummarySchema,
1440
+ InitiativeCreateSchema,
1441
+ InitiativeUpdateSchema,
1316
1442
  KnowledgeArtifactDetailSchema,
1317
1443
  KnowledgeArtifactSummarySchema,
1318
1444
  KnowledgeInventoryLayerSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaddo/cli",
3
- "version": "3.108.0",
3
+ "version": "3.109.0",
4
4
  "description": "Knowledge Driven Development toolkit",
5
5
  "license": "MIT",
6
6
  "repository": {