@devpad/cli 2.3.4 → 2.3.6

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.
Files changed (2) hide show
  1. package/dist/index.js +1569 -31
  2. package/package.json +6 -5
package/dist/index.js CHANGED
@@ -12453,9 +12453,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
12453
12453
  _chainOrCallSubCommandHook(promise, subCommand, event) {
12454
12454
  let result = promise;
12455
12455
  if (this._lifeCycleHooks[event] !== undefined) {
12456
- this._lifeCycleHooks[event].forEach((hook) => {
12456
+ this._lifeCycleHooks[event].forEach((hook2) => {
12457
12457
  result = this._chainOrCall(result, () => {
12458
- return hook(this, subCommand);
12458
+ return hook2(this, subCommand);
12459
12459
  });
12460
12460
  });
12461
12461
  }
@@ -15824,7 +15824,7 @@ var require_emoji_regex = __commonJS(function(exports, module) {
15824
15824
  };
15825
15825
  });
15826
15826
 
15827
- // ../api/dist/chunk-XHTCNYWS.js
15827
+ // ../api/dist/chunk-KRYLGBPJ.js
15828
15828
  init_drizzle_orm();
15829
15829
  init_sqlite_core();
15830
15830
  init_zod();
@@ -15878,6 +15878,7 @@ var api_keys = sqliteTable("api_keys", {
15878
15878
  name: text("name"),
15879
15879
  note: text("note"),
15880
15880
  scope: text("scope", { enum: ["devpad", "blog", "media", "pulse", "all"] }).notNull().default("all"),
15881
+ project_id: text("project_id").references(() => project.id),
15881
15882
  enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
15882
15883
  last_used_at: text("last_used_at"),
15883
15884
  ...timestamps(),
@@ -15897,7 +15898,8 @@ var project = sqliteTable("project", {
15897
15898
  link_text: text("link_text"),
15898
15899
  visibility: text("visibility", { enum: ["PUBLIC", "PRIVATE", "HIDDEN", "ARCHIVED", "DRAFT", "DELETED"] }).notNull().default("PRIVATE"),
15899
15900
  current_version: text("current_version"),
15900
- scan_branch: text("scan_branch")
15901
+ scan_branch: text("scan_branch"),
15902
+ github_autoclose: integer("github_autoclose", { mode: "boolean" }).notNull().default(false)
15901
15903
  });
15902
15904
  var ACTIONS = [
15903
15905
  "CREATE_TASK",
@@ -15917,7 +15919,8 @@ var ACTIONS = [
15917
15919
  "DELETE_MILESTONE",
15918
15920
  "CREATE_CHECKLIST",
15919
15921
  "UPDATE_CHECKLIST",
15920
- "DELETE_CHECKLIST"
15922
+ "DELETE_CHECKLIST",
15923
+ "ADVANCE_STAGE"
15921
15924
  ];
15922
15925
  var action = sqliteTable("action", {
15923
15926
  ...owned_entity("action"),
@@ -15972,6 +15975,7 @@ var TASK_KINDS = ["task", "phase", "approval"];
15972
15975
  var COMPLETION_POLICIES = ["manual", "auto_children"];
15973
15976
  var COMPLETED_VIA_VALUES = ["user", "api", "policy"];
15974
15977
  var TASK_LINK_KINDS = ["blocks", "relates_to", "references", "discovered_from", "tracks_metric"];
15978
+ var SDLC_STAGES = ["ideate", "plan", "build", "review", "deploy", "live"];
15975
15979
  var task = sqliteTable("task", {
15976
15980
  ...owned_entity("task"),
15977
15981
  title: text("title").notNull(),
@@ -15992,7 +15996,8 @@ var task = sqliteTable("task", {
15992
15996
  completion_policy: text("completion_policy", { enum: COMPLETION_POLICIES }).notNull().default("manual"),
15993
15997
  completed_via: text("completed_via", { enum: COMPLETED_VIA_VALUES }),
15994
15998
  claimed_by: text("claimed_by"),
15995
- claimed_at: text("claimed_at")
15999
+ claimed_at: text("claimed_at"),
16000
+ stage: text("stage", { enum: SDLC_STAGES })
15996
16001
  }, (table3) => [index("task_parent_id_idx").on(table3.parent_id)]);
15997
16002
  var task_link = sqliteTable("task_link", {
15998
16003
  ...entity2("link"),
@@ -16029,7 +16034,13 @@ var TASK_EVENT_KINDS = [
16029
16034
  "edge.removed",
16030
16035
  "node.children_all_done",
16031
16036
  "policy.fired",
16032
- "node.completion_stale"
16037
+ "node.completion_stale",
16038
+ "doc.pushed",
16039
+ "thread.opened",
16040
+ "thread.resolved",
16041
+ "signoff.requested",
16042
+ "signoff.decided",
16043
+ "stage.advanced"
16033
16044
  ];
16034
16045
  var TASK_EVENT_ACTORS = ["user", "api", "policy", "github"];
16035
16046
  var TASK_EVENT_DISPATCH_STATUSES = ["pending", "dispatched"];
@@ -16048,6 +16059,74 @@ var task_event = sqliteTable("task_event", {
16048
16059
  index("task_event_subject_id_idx").on(table3.subject_id),
16049
16060
  index("task_event_dispatch_status_idx").on(table3.dispatch_status)
16050
16061
  ]);
16062
+ var hook = sqliteTable("hook", {
16063
+ ...entity2("hook"),
16064
+ project_id: text("project_id").notNull().references(() => project.id),
16065
+ enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
16066
+ trigger: text("trigger", { mode: "json" }).notNull(),
16067
+ action: text("action", { mode: "json" }).notNull()
16068
+ }, (table3) => [index("hook_project_id_idx").on(table3.project_id)]);
16069
+ var HOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed_transient", "failed_permanent"];
16070
+ var hook_delivery = sqliteTable("hook_delivery", {
16071
+ id: text("id").primaryKey(),
16072
+ hook_id: text("hook_id").notNull().references(() => hook.id),
16073
+ event_id: text("event_id").notNull(),
16074
+ status: text("status", { enum: HOOK_DELIVERY_STATUSES }).notNull().default("pending"),
16075
+ attempts: integer("attempts").notNull().default(0),
16076
+ last_error: text("last_error"),
16077
+ ...timestamps()
16078
+ }, (table3) => [
16079
+ index("hook_delivery_hook_id_idx").on(table3.hook_id),
16080
+ index("hook_delivery_status_idx").on(table3.status)
16081
+ ]);
16082
+ var github_webhook_event = sqliteTable("github_webhook_event", {
16083
+ id: text("id").primaryKey(),
16084
+ delivery_guid: text("delivery_guid").notNull(),
16085
+ event_type: text("event_type").notNull(),
16086
+ processed_at: text("processed_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
16087
+ }, (table3) => [index("github_webhook_event_delivery_guid_idx").on(table3.delivery_guid)]);
16088
+ var DOCUMENT_KINDS = ["plan", "design", "interface"];
16089
+ var DOCUMENT_STATUSES = ["draft", "in_review", "approved"];
16090
+ var document = sqliteTable("document", {
16091
+ ...entity2("doc"),
16092
+ project_id: text("project_id").notNull().references(() => project.id),
16093
+ task_id: text("task_id").references(() => task.id),
16094
+ kind: text("kind", { enum: DOCUMENT_KINDS }).notNull(),
16095
+ title: text("title").notNull(),
16096
+ head_version: text("head_version"),
16097
+ status: text("status", { enum: DOCUMENT_STATUSES }).notNull().default("draft")
16098
+ }, (table3) => [index("document_project_id_idx").on(table3.project_id), index("document_task_id_idx").on(table3.task_id)]);
16099
+ var THREAD_STATUSES = ["open", "addressed", "resolved", "orphaned"];
16100
+ var annotation_thread = sqliteTable("annotation_thread", {
16101
+ ...id("thread"),
16102
+ document_id: text("document_id").notNull().references(() => document.id),
16103
+ thread_id: text("thread_id").notNull(),
16104
+ status: text("status", { enum: THREAD_STATUSES }).notNull().default("open"),
16105
+ blocking: int("blocking", { mode: "boolean" }).notNull().default(false),
16106
+ ...timestamps()
16107
+ }, (table3) => [
16108
+ unique("annotation_thread_unique").on(table3.document_id, table3.thread_id),
16109
+ index("annotation_thread_document_id_idx").on(table3.document_id),
16110
+ index("annotation_thread_status_idx").on(table3.status)
16111
+ ]);
16112
+ var SIGNOFF_SUBJECT_KINDS = ["doc_version", "stage", "pipeline_gate"];
16113
+ var SIGNOFF_CHECKPOINTS = ["plan", "types", "design"];
16114
+ var SIGNOFF_DECISIONS = ["approved", "changes_requested", "auto"];
16115
+ var signoff = sqliteTable("signoff", {
16116
+ ...entity2("signoff"),
16117
+ subject_kind: text("subject_kind", { enum: SIGNOFF_SUBJECT_KINDS }).notNull(),
16118
+ subject_id: text("subject_id").notNull(),
16119
+ checkpoint: text("checkpoint", { enum: SIGNOFF_CHECKPOINTS }).notNull(),
16120
+ task_id: text("task_id").references(() => task.id),
16121
+ decision: text("decision", { enum: SIGNOFF_DECISIONS }),
16122
+ decided_by: text("decided_by").references(() => user.id),
16123
+ decided_at: text("decided_at"),
16124
+ reason: text("reason"),
16125
+ content_hash: text("content_hash")
16126
+ }, (table3) => [
16127
+ index("signoff_subject_idx").on(table3.subject_kind, table3.subject_id),
16128
+ index("signoff_task_id_idx").on(table3.task_id)
16129
+ ]);
16051
16130
  var checklist = sqliteTable("checklist", {
16052
16131
  ...entity2("checklist"),
16053
16132
  task_id: text("task_id").notNull().references(() => task.id),
@@ -16241,6 +16320,13 @@ var task_rollup_relations = relations(task_rollup, ({ one }) => ({
16241
16320
  var task_event_relations = relations(task_event, ({ one }) => ({
16242
16321
  subject: one(task, { fields: [task_event.subject_id], references: [task.id] })
16243
16322
  }));
16323
+ var hook_relations = relations(hook, ({ one, many }) => ({
16324
+ project: one(project, { fields: [hook.project_id], references: [project.id] }),
16325
+ deliveries: many(hook_delivery)
16326
+ }));
16327
+ var hook_delivery_relations = relations(hook_delivery, ({ one }) => ({
16328
+ hook: one(hook, { fields: [hook_delivery.hook_id], references: [hook.id] })
16329
+ }));
16244
16330
  var checklist_relations = relations(checklist, ({ one, many }) => ({
16245
16331
  task: one(task, { fields: [checklist.task_id], references: [task.id] }),
16246
16332
  items: many(checklist_item)
@@ -16282,6 +16368,18 @@ var pipeline_analysis_template_relations = relations(pipeline_analysis_template,
16282
16368
  var pipeline_oidc_trust_relations = relations(pipeline_oidc_trust, ({ one }) => ({
16283
16369
  owner: one(user, { fields: [pipeline_oidc_trust.owner_id], references: [user.id] })
16284
16370
  }));
16371
+ var document_relations = relations(document, ({ one, many }) => ({
16372
+ project: one(project, { fields: [document.project_id], references: [project.id] }),
16373
+ task: one(task, { fields: [document.task_id], references: [task.id] }),
16374
+ threads: many(annotation_thread)
16375
+ }));
16376
+ var annotation_thread_relations = relations(annotation_thread, ({ one }) => ({
16377
+ document: one(document, { fields: [annotation_thread.document_id], references: [document.id] })
16378
+ }));
16379
+ var signoff_relations = relations(signoff, ({ one }) => ({
16380
+ task: one(task, { fields: [signoff.task_id], references: [task.id] }),
16381
+ decided_by_user: one(user, { fields: [signoff.decided_by], references: [user.id] })
16382
+ }));
16285
16383
  var upsert_project = exports_external.object({
16286
16384
  id: exports_external.string().optional().nullable(),
16287
16385
  project_id: exports_external.string(),
@@ -16613,8 +16711,153 @@ var task_event_payload = exports_external.discriminatedUnion("kind", [
16613
16711
  exports_external.object({ kind: exports_external.literal("edge.removed"), link_kind: task_link_kind, dst_id: exports_external.string().nullable() }),
16614
16712
  exports_external.object({ kind: exports_external.literal("node.children_all_done") }),
16615
16713
  exports_external.object({ kind: exports_external.literal("policy.fired"), policy: exports_external.enum(COMPLETION_POLICIES) }),
16616
- exports_external.object({ kind: exports_external.literal("node.completion_stale"), child_id: exports_external.string() })
16714
+ exports_external.object({ kind: exports_external.literal("node.completion_stale"), child_id: exports_external.string() }),
16715
+ exports_external.object({ kind: exports_external.literal("doc.pushed"), document_id: exports_external.string(), version: exports_external.string() }),
16716
+ exports_external.object({ kind: exports_external.literal("thread.opened"), document_id: exports_external.string(), thread_id: exports_external.string() }),
16717
+ exports_external.object({ kind: exports_external.literal("thread.resolved"), document_id: exports_external.string(), thread_id: exports_external.string() }),
16718
+ exports_external.object({
16719
+ kind: exports_external.literal("signoff.requested"),
16720
+ subject_kind: exports_external.enum(SIGNOFF_SUBJECT_KINDS),
16721
+ subject_id: exports_external.string(),
16722
+ checkpoint: exports_external.enum(SIGNOFF_CHECKPOINTS)
16723
+ }),
16724
+ exports_external.object({
16725
+ kind: exports_external.literal("signoff.decided"),
16726
+ subject_kind: exports_external.enum(SIGNOFF_SUBJECT_KINDS),
16727
+ subject_id: exports_external.string(),
16728
+ checkpoint: exports_external.enum(SIGNOFF_CHECKPOINTS),
16729
+ decision: exports_external.enum(SIGNOFF_DECISIONS)
16730
+ }),
16731
+ exports_external.object({
16732
+ kind: exports_external.literal("stage.advanced"),
16733
+ from: exports_external.enum(SDLC_STAGES).nullable(),
16734
+ to: exports_external.enum(SDLC_STAGES),
16735
+ override: exports_external.boolean()
16736
+ })
16617
16737
  ]);
16738
+ var document_kind = exports_external.enum(DOCUMENT_KINDS);
16739
+ var push_doc_request = exports_external.object({
16740
+ document_id: exports_external.string().optional(),
16741
+ project_id: exports_external.string(),
16742
+ task_id: exports_external.string().nullable().optional(),
16743
+ kind: document_kind,
16744
+ title: exports_external.string().min(1),
16745
+ html: exports_external.string()
16746
+ });
16747
+ var thread_anchor = exports_external.object({
16748
+ quote: exports_external.string().min(1),
16749
+ prefix: exports_external.string(),
16750
+ suffix: exports_external.string(),
16751
+ start: exports_external.number().int().nonnegative(),
16752
+ end: exports_external.number().int().nonnegative()
16753
+ });
16754
+ var thread_entry = exports_external.object({
16755
+ author: exports_external.string().min(1),
16756
+ channel: exports_external.enum(["user", "api"]),
16757
+ body: exports_external.string().min(1),
16758
+ at: exports_external.string()
16759
+ });
16760
+ var thread_status = exports_external.enum(THREAD_STATUSES);
16761
+ var thread_marker = exports_external.object({
16762
+ id: exports_external.string().min(1),
16763
+ anchor: thread_anchor,
16764
+ status: thread_status,
16765
+ blocking: exports_external.boolean(),
16766
+ entries: exports_external.array(thread_entry).min(1)
16767
+ });
16768
+ var create_thread_request = exports_external.object({
16769
+ quote: exports_external.string().min(1),
16770
+ prefix: exports_external.string(),
16771
+ suffix: exports_external.string(),
16772
+ start: exports_external.number().int().nonnegative(),
16773
+ end: exports_external.number().int().nonnegative(),
16774
+ body: exports_external.string().min(1),
16775
+ blocking: exports_external.boolean().optional().default(false)
16776
+ });
16777
+ var reply_thread_request = exports_external.object({ body: exports_external.string().min(1) });
16778
+ var toggle_blocking_request = exports_external.object({ blocking: exports_external.boolean() });
16779
+ var signoff_subject_kind = exports_external.enum(SIGNOFF_SUBJECT_KINDS);
16780
+ var signoff_checkpoint = exports_external.enum(SIGNOFF_CHECKPOINTS);
16781
+ var request_checkpoint_request = exports_external.object({
16782
+ project_id: exports_external.string(),
16783
+ subject_kind: signoff_subject_kind,
16784
+ subject_id: exports_external.string(),
16785
+ checkpoint: signoff_checkpoint,
16786
+ blocks: exports_external.array(exports_external.string()).default([])
16787
+ });
16788
+ var decide_checkpoint_request = exports_external.object({
16789
+ decision: exports_external.union([exports_external.literal("approved"), exports_external.literal("changes_requested")]),
16790
+ reason: exports_external.string().optional()
16791
+ });
16792
+ var sdlc_stage = exports_external.enum(SDLC_STAGES);
16793
+ var advance_stage_request = exports_external.object({
16794
+ to: sdlc_stage,
16795
+ override: exports_external.boolean().optional().default(false),
16796
+ reason: exports_external.string().optional()
16797
+ });
16798
+ var push_interface_report_request = exports_external.object({
16799
+ document_id: exports_external.string().optional(),
16800
+ project_id: exports_external.string(),
16801
+ task_id: exports_external.string().nullable().optional(),
16802
+ title: exports_external.string().min(1),
16803
+ normalized: exports_external.string()
16804
+ });
16805
+ var REVIEW_ITEM_KINDS = ["signoff", "annotation", "pipeline_gate", "scan_diff"];
16806
+ var review_item = exports_external.object({
16807
+ kind: exports_external.enum(REVIEW_ITEM_KINDS),
16808
+ subject_id: exports_external.string(),
16809
+ title: exports_external.string(),
16810
+ project_id: exports_external.string().nullable(),
16811
+ created_at: exports_external.string(),
16812
+ path: exports_external.string()
16813
+ });
16814
+ var reviews_pending_response = exports_external.object({ items: exports_external.array(review_item) });
16815
+ var hook_selector = exports_external.object({
16816
+ subject_kind: exports_external.enum(TASK_KINDS).optional(),
16817
+ tag: exports_external.string().optional(),
16818
+ ancestor_id: exports_external.string().optional()
16819
+ });
16820
+ var hook_trigger = exports_external.object({
16821
+ kinds: exports_external.array(exports_external.enum(TASK_EVENT_KINDS)).min(1),
16822
+ selector: hook_selector.default({})
16823
+ });
16824
+ var hook_action_input = exports_external.discriminatedUnion("kind", [
16825
+ exports_external.object({ kind: exports_external.literal("webhook"), url: exports_external.string().url(), secret: exports_external.string().min(1).optional() }),
16826
+ exports_external.object({
16827
+ kind: exports_external.literal("vault"),
16828
+ scope: exports_external.string().min(1),
16829
+ op: exports_external.string().min(1),
16830
+ args: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
16831
+ }),
16832
+ exports_external.object({ kind: exports_external.literal("pipeline"), package_id: exports_external.string().min(1) })
16833
+ ]);
16834
+ var hook_action_stored = exports_external.discriminatedUnion("kind", [
16835
+ exports_external.object({ kind: exports_external.literal("webhook"), url: exports_external.string().url(), secret_encrypted: exports_external.string().optional() }),
16836
+ exports_external.object({
16837
+ kind: exports_external.literal("vault"),
16838
+ scope: exports_external.string().min(1),
16839
+ op: exports_external.string().min(1),
16840
+ args: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
16841
+ }),
16842
+ exports_external.object({ kind: exports_external.literal("pipeline"), package_id: exports_external.string().min(1) })
16843
+ ]);
16844
+ var hook_action_public = exports_external.discriminatedUnion("kind", [
16845
+ exports_external.object({ kind: exports_external.literal("webhook"), url: exports_external.string().url(), has_secret: exports_external.boolean() }),
16846
+ exports_external.object({
16847
+ kind: exports_external.literal("vault"),
16848
+ scope: exports_external.string().min(1),
16849
+ op: exports_external.string().min(1),
16850
+ args: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
16851
+ }),
16852
+ exports_external.object({ kind: exports_external.literal("pipeline"), package_id: exports_external.string().min(1) })
16853
+ ]);
16854
+ var upsert_hook = exports_external.object({
16855
+ id: exports_external.string().optional(),
16856
+ project_id: exports_external.string(),
16857
+ enabled: exports_external.boolean().default(true),
16858
+ trigger: hook_trigger,
16859
+ action: hook_action_input
16860
+ });
16618
16861
 
16619
16862
  // ../api/dist/chunk-5L3AUVMM.js
16620
16863
  init_dist();
@@ -16917,12 +17160,8 @@ function handleHttpResponse(response) {
16917
17160
  throw new AuthenticationError("Invalid or expired API key");
16918
17161
  case HTTP_STATUS.NOT_FOUND:
16919
17162
  throw new ApiError("Resource not found", { statusCode: HTTP_STATUS.NOT_FOUND });
16920
- case HTTP_STATUS.BAD_REQUEST:
16921
- break;
16922
17163
  default:
16923
- if (!response.ok) {
16924
- throw new ApiError(`Request failed: ${response.statusText}`, { statusCode: response.status });
16925
- }
17164
+ break;
16926
17165
  }
16927
17166
  }
16928
17167
  async function handleResponseError(response) {
@@ -16933,11 +17172,13 @@ async function handleResponseError(response) {
16933
17172
  const raw = JSON.parse(errorText);
16934
17173
  parsedError = raw;
16935
17174
  } catch {}
16936
- if (response.status === HTTP_STATUS.BAD_REQUEST && parsedError?.error?.name === "ZodError") {
16937
- const zodErrorDetails = parsedError.error.issues ? JSON.stringify(parsedError.error) : errorMessage;
17175
+ const structuredError = typeof parsedError?.error === "object" ? parsedError.error : undefined;
17176
+ if (response.status === HTTP_STATUS.BAD_REQUEST && structuredError?.name === "ZodError") {
17177
+ const zodErrorDetails = structuredError.issues ? JSON.stringify(structuredError) : errorMessage;
16938
17178
  throw new ValidationError(zodErrorDetails);
16939
17179
  }
16940
- throw new ApiError(errorMessage, { statusCode: response.status });
17180
+ const message = typeof parsedError?.error === "string" ? parsedError.error : errorMessage;
17181
+ throw new ApiError(message, { statusCode: response.status });
16941
17182
  }
16942
17183
  function handleNetworkError(error) {
16943
17184
  const message = error instanceof Error ? error.message : "Unknown network error";
@@ -17316,6 +17557,12 @@ var ApiClient2 = class {
17316
17557
  delete: (id2) => wrap(() => this.clients.milestones.delete(`/milestones/${id2}`)),
17317
17558
  goals: (id2) => wrap(() => this.clients.milestones.get(`/milestones/${id2}/goals`))
17318
17559
  };
17560
+ this.hooks = {
17561
+ list: (project_id) => wrap(() => this.clients.hooks.get("/hooks", { query: { project_id } })),
17562
+ upsert: (data) => wrap(() => data.id ? this.clients.hooks.patch(`/hooks/${data.id}`, { body: data }) : this.clients.hooks.post("/hooks", { body: data })),
17563
+ delete: (id2) => wrap(() => this.clients.hooks.delete(`/hooks/${id2}`)),
17564
+ deliveries: (id2, status) => wrap(() => this.clients.hooks.get(`/hooks/${id2}/deliveries`, status ? { query: { status } } : {}))
17565
+ };
17319
17566
  this.goals = {
17320
17567
  list: () => wrap(() => this.clients.goals.get("/goals")),
17321
17568
  find: (id2) => wrap(() => this.clients.goals.get(`/goals/${id2}`)),
@@ -17402,6 +17649,7 @@ var ApiClient2 = class {
17402
17649
  near: (id2) => wrap(() => this.clients.tasks.get(`/tasks/${id2}/near`)),
17403
17650
  claim: (id2, data) => wrap(() => this.clients.tasks.post(`/tasks/${id2}/claim`, { body: data })),
17404
17651
  done: (id2, data) => wrap(() => this.clients.tasks.post(`/tasks/${id2}/done`, { body: data })),
17652
+ advanceStage: (id2, data) => wrap(() => this.clients.tasks.post(`/tasks/${id2}/stage`, { body: data })),
17405
17653
  link: (data) => wrap(() => this.clients.tasks.post("/tasks/link", { body: data })),
17406
17654
  unlink: (link_id) => wrap(() => this.clients.tasks.delete(`/tasks/link/${link_id}`)),
17407
17655
  apply: (data) => wrap(() => this.clients.tasks.post("/tasks/apply", { body: data }))
@@ -17409,6 +17657,44 @@ var ApiClient2 = class {
17409
17657
  this.tags = {
17410
17658
  list: () => wrap(() => this.clients.tags.get("/tags"))
17411
17659
  };
17660
+ this.docs = {
17661
+ list: (filters) => wrap(() => {
17662
+ const query = { project_id: filters.project_id };
17663
+ if (filters.task_id)
17664
+ query.task_id = filters.task_id;
17665
+ return this.clients.docs.get("/docs", { query });
17666
+ }),
17667
+ push: (data) => wrap(() => this.clients.docs.post("/docs", { body: data })),
17668
+ pull: (id2, version2) => wrap(() => this.clients.docs.get(`/docs/${id2}`, version2 ? { query: { version: version2 } } : {})),
17669
+ versions: (id2) => wrap(() => this.clients.docs.get(`/docs/${id2}/versions`)),
17670
+ createThread: (document_id, data) => wrap(() => this.clients.docs.post(`/docs/${document_id}/threads`, { body: data })),
17671
+ replyThread: (document_id, thread_id, body) => wrap(() => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/reply`, { body: { body } })),
17672
+ resolveThread: (document_id, thread_id) => wrap(() => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/resolve`, {})),
17673
+ toggleBlocking: (document_id, thread_id, blocking) => wrap(() => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/blocking`, { body: { blocking } })),
17674
+ unresolved: (filters) => wrap(() => {
17675
+ const query = {};
17676
+ if (filters.project_id)
17677
+ query.project_id = filters.project_id;
17678
+ if (filters.document_id)
17679
+ query.document_id = filters.document_id;
17680
+ return this.clients.docs.get("/docs/annotations/unresolved", { query });
17681
+ }),
17682
+ pushInterfaceReport: (data) => wrap(() => this.clients.docs.post("/docs/interface", { body: data })),
17683
+ interfaceStatus: (filters) => wrap(() => {
17684
+ const query = { project_id: filters.project_id, title: filters.title };
17685
+ if (filters.task_id)
17686
+ query.task_id = filters.task_id;
17687
+ return this.clients.docs.get("/docs/interface/status", { query });
17688
+ })
17689
+ };
17690
+ this.signoffs = {
17691
+ request: (data) => wrap(() => this.clients.signoffs.post("/signoffs", { body: data })),
17692
+ find: (id2) => wrap(() => this.clients.signoffs.get(`/signoffs/${id2}`)),
17693
+ decide: (id2, data) => wrap(() => this.clients.signoffs.post(`/signoffs/${id2}/decide`, { body: data }))
17694
+ };
17695
+ this.reviews = {
17696
+ pending: () => wrap(() => this.clients.reviews.get("/reviews/pending"))
17697
+ };
17412
17698
  this.github = {
17413
17699
  repos: () => wrap(() => this.clients.github.get("/repos")),
17414
17700
  branches: (owner, repo) => wrap(() => this.clients.github.get(`/repos/${owner}/${repo}/branches`))
@@ -17773,7 +18059,11 @@ var ApiClient2 = class {
17773
18059
  blog: new ApiClient({ ...clientOptions, category: "blog" }),
17774
18060
  media: new ApiClient({ ...clientOptions, category: "media" }),
17775
18061
  pulse: new ApiClient({ ...clientOptions, base_url: `${base_url}/pulse`, category: "pulse" }),
17776
- pipelines: new ApiClient({ ...clientOptions, category: "pipelines" })
18062
+ pipelines: new ApiClient({ ...clientOptions, category: "pipelines" }),
18063
+ hooks: new ApiClient({ ...clientOptions, category: "hooks" }),
18064
+ docs: new ApiClient({ ...clientOptions, category: "docs" }),
18065
+ signoffs: new ApiClient({ ...clientOptions, category: "signoffs" }),
18066
+ reviews: new ApiClient({ ...clientOptions, category: "reviews" })
17777
18067
  };
17778
18068
  }
17779
18069
  history() {
@@ -17859,6 +18149,16 @@ var milestone_by_id = exports_external.object({
17859
18149
  var goal_by_id = exports_external.object({
17860
18150
  id: exports_external.string().describe("Goal ID")
17861
18151
  });
18152
+ var hook_filters = exports_external.object({
18153
+ project_id: exports_external.string().describe("Project ID to list hooks for")
18154
+ });
18155
+ var hook_by_id = exports_external.object({
18156
+ id: exports_external.string().describe("Hook ID")
18157
+ });
18158
+ var hook_deliveries_input = exports_external.object({
18159
+ id: exports_external.string().describe("Hook ID"),
18160
+ status: exports_external.enum(["pending", "delivered", "failed_transient", "failed_permanent"]).optional().describe("Filter by delivery status — use failed_permanent to see the DLQ")
18161
+ });
17862
18162
  var github_branches = exports_external.object({
17863
18163
  owner: exports_external.string().describe("Repository owner"),
17864
18164
  repo: exports_external.string().describe("Repository name")
@@ -17956,6 +18256,30 @@ var tools = {
17956
18256
  finished_at: input.finished_at
17957
18257
  }))
17958
18258
  }),
18259
+ devpad_hooks_list: define_tool({
18260
+ name: "devpad_hooks_list",
18261
+ description: "List hooks configured for a project",
18262
+ inputSchema: hook_filters,
18263
+ execute: async (client, input) => unwrap2(await client.hooks.list(input.project_id))
18264
+ }),
18265
+ devpad_hooks_upsert: define_tool({
18266
+ name: "devpad_hooks_upsert",
18267
+ description: "Create or update a hook (webhook/vault/pipeline action fired on matching task_event kinds). Pass 'id' to update.",
18268
+ inputSchema: upsert_hook,
18269
+ execute: async (client, input) => unwrap2(await client.hooks.upsert(input))
18270
+ }),
18271
+ devpad_hooks_delete: define_tool({
18272
+ name: "devpad_hooks_delete",
18273
+ description: "Delete a hook",
18274
+ inputSchema: hook_by_id,
18275
+ execute: async (client, input) => unwrap2(await client.hooks.delete(input.id))
18276
+ }),
18277
+ devpad_hooks_deliveries: define_tool({
18278
+ name: "devpad_hooks_deliveries",
18279
+ description: "List delivery attempts for a hook, optionally filtered by status (the DLQ is status=failed_permanent)",
18280
+ inputSchema: hook_deliveries_input,
18281
+ execute: async (client, input) => unwrap2(await client.hooks.deliveries(input.id, input.status))
18282
+ }),
17959
18283
  devpad_goals_list: define_tool({
17960
18284
  name: "devpad_goals_list",
17961
18285
  description: "List goals for authenticated user",
@@ -18147,6 +18471,15 @@ var tools = {
18147
18471
  }),
18148
18472
  execute: async (client, input) => unwrap2(await client.tasks.unlink(input.id))
18149
18473
  }),
18474
+ devpad_tasks_advance_stage: define_tool({
18475
+ name: "devpad_tasks_advance_stage",
18476
+ description: "Advance a task's SDLC stage (ideate|plan|build|review|deploy|live). Gated hops (plan->build needs an approved plan checkpoint; review->deploy needs approved types + design when a design doc exists) 409 naming what's missing unless override:true, which always succeeds but is audited.",
18477
+ inputSchema: advance_stage_request.extend({ id: exports_external.string().describe("Task ID") }),
18478
+ execute: async (client, input) => {
18479
+ const { id: id2, ...rest } = input;
18480
+ return unwrap2(await client.tasks.advanceStage(id2, rest));
18481
+ }
18482
+ }),
18150
18483
  devpad_tasks_apply: define_tool({
18151
18484
  name: "devpad_tasks_apply",
18152
18485
  description: "Batch apply create/update/reparent/link/unlink/claim/complete ops atomically, with $0/$1… temp handles for subtree creation. Replaying the same idempotency_key returns the prior response verbatim.",
@@ -18696,6 +19029,128 @@ var tools = {
18696
19029
  owner_id: exports_external.string().describe("Owner ID (must match the policy's owner)")
18697
19030
  }),
18698
19031
  execute: async (client, input) => unwrap2(await client.pipelines.oidc_trust.delete(input.id, { owner_id: input.owner_id }))
19032
+ }),
19033
+ devpad_docs_list: define_tool({
19034
+ name: "devpad_docs_list",
19035
+ description: "List documents for a project (optionally filtered to one task)",
19036
+ inputSchema: exports_external.object({
19037
+ project_id: exports_external.string().describe("Project ID"),
19038
+ task_id: exports_external.string().optional().describe("Filter to documents attached to this task")
19039
+ }),
19040
+ execute: async (client, input) => unwrap2(await client.docs.list(input))
19041
+ }),
19042
+ devpad_docs_push: define_tool({
19043
+ name: "devpad_docs_push",
19044
+ description: "Push HTML content as a new document (omit document_id) or a new version on an existing one. HTML is sanitized server-side before storage — script/iframe/object/embed/form, event handlers, and javascript:/data: URLs never survive.",
19045
+ inputSchema: push_doc_request,
19046
+ execute: async (client, input) => unwrap2(await client.docs.push(input))
19047
+ }),
19048
+ devpad_docs_pull: define_tool({
19049
+ name: "devpad_docs_pull",
19050
+ description: "Pull a document's content at a specific version (default: head)",
19051
+ inputSchema: exports_external.object({
19052
+ id: exports_external.string().describe("Document ID"),
19053
+ version: exports_external.string().optional().describe("Corpus version — defaults to head")
19054
+ }),
19055
+ execute: async (client, input) => unwrap2(await client.docs.pull(input.id, input.version))
19056
+ }),
19057
+ devpad_docs_versions: define_tool({
19058
+ name: "devpad_docs_versions",
19059
+ description: "Full version history for a document, newest first (the lineage walk)",
19060
+ inputSchema: exports_external.object({
19061
+ id: exports_external.string().describe("Document ID")
19062
+ }),
19063
+ execute: async (client, input) => unwrap2(await client.docs.versions(input.id))
19064
+ }),
19065
+ devpad_annotations_create: define_tool({
19066
+ name: "devpad_annotations_create",
19067
+ description: "Open a new annotation thread on a document, anchored to an exact quote (with prefix/suffix context + char offsets for re-anchoring across edits)",
19068
+ inputSchema: create_thread_request.extend({ document_id: exports_external.string().describe("Document ID") }),
19069
+ execute: async (client, input) => {
19070
+ const { document_id, ...rest } = input;
19071
+ return unwrap2(await client.docs.createThread(document_id, rest));
19072
+ }
19073
+ }),
19074
+ devpad_annotations_reply: define_tool({
19075
+ name: "devpad_annotations_reply",
19076
+ description: "Reply to an existing annotation thread",
19077
+ inputSchema: exports_external.object({
19078
+ document_id: exports_external.string().describe("Document ID"),
19079
+ thread_id: exports_external.string().describe("Thread ID (from the marker JSON, not the document ID)"),
19080
+ body: exports_external.string().min(1).describe("Reply text")
19081
+ }),
19082
+ execute: async (client, input) => unwrap2(await client.docs.replyThread(input.document_id, input.thread_id, input.body))
19083
+ }),
19084
+ devpad_annotations_resolve: define_tool({
19085
+ name: "devpad_annotations_resolve",
19086
+ description: "Mark an annotation thread resolved",
19087
+ inputSchema: exports_external.object({
19088
+ document_id: exports_external.string().describe("Document ID"),
19089
+ thread_id: exports_external.string().describe("Thread ID")
19090
+ }),
19091
+ execute: async (client, input) => unwrap2(await client.docs.resolveThread(input.document_id, input.thread_id))
19092
+ }),
19093
+ devpad_annotations_toggle_blocking: define_tool({
19094
+ name: "devpad_annotations_toggle_blocking",
19095
+ description: "Toggle whether an annotation thread blocks approval",
19096
+ inputSchema: exports_external.object({
19097
+ document_id: exports_external.string().describe("Document ID"),
19098
+ thread_id: exports_external.string().describe("Thread ID"),
19099
+ blocking: exports_external.boolean()
19100
+ }),
19101
+ execute: async (client, input) => unwrap2(await client.docs.toggleBlocking(input.document_id, input.thread_id, input.blocking))
19102
+ }),
19103
+ devpad_interface_push: define_tool({
19104
+ name: "devpad_interface_push",
19105
+ description: "Push already-normalized declaration text as a new interface-doc version. The server independently recomputes additive-vs-breaking against its own stored previous content and auto-approves additive diffs against an approved base.",
19106
+ inputSchema: push_interface_report_request,
19107
+ execute: async (client, input) => unwrap2(await client.docs.pushInterfaceReport(input))
19108
+ }),
19109
+ devpad_interface_status: define_tool({
19110
+ name: "devpad_interface_status",
19111
+ description: "Get the approved/auto content_hash for an interface doc, for a client-side hash comparison (the `check` verb)",
19112
+ inputSchema: exports_external.object({
19113
+ project_id: exports_external.string().describe("Project ID"),
19114
+ task_id: exports_external.string().optional().describe("Task ID"),
19115
+ title: exports_external.string().describe("The interface document's title (package name)")
19116
+ }),
19117
+ execute: async (client, input) => unwrap2(await client.docs.interfaceStatus(input))
19118
+ }),
19119
+ devpad_reviews_pending: define_tool({
19120
+ name: "devpad_reviews_pending",
19121
+ description: "The human's queue — one typed aggregate across pending signoff checkpoints, open blocking annotation threads, pending pipeline manual gates, and pending scanner diffs, scoped to the authenticated user",
19122
+ inputSchema: exports_external.object({}),
19123
+ execute: async (client) => unwrap2(await client.reviews.pending())
19124
+ }),
19125
+ devpad_annotations_unresolved: define_tool({
19126
+ name: "devpad_annotations_unresolved",
19127
+ description: "List pending annotation threads (anything not resolved) for a project or a specific document",
19128
+ inputSchema: exports_external.object({
19129
+ project_id: exports_external.string().optional().describe("Project ID"),
19130
+ document_id: exports_external.string().optional().describe("Document ID")
19131
+ }),
19132
+ execute: async (client, input) => unwrap2(await client.docs.unresolved(input))
19133
+ }),
19134
+ devpad_signoffs_request: define_tool({
19135
+ name: "devpad_signoffs_request",
19136
+ description: "Request a human signoff checkpoint — creates a pending approval node that blocks the named downstream tasks until decided",
19137
+ inputSchema: request_checkpoint_request,
19138
+ execute: async (client, input) => unwrap2(await client.signoffs.request(input))
19139
+ }),
19140
+ devpad_signoffs_get: define_tool({
19141
+ name: "devpad_signoffs_get",
19142
+ description: "Get a signoff checkpoint's current state",
19143
+ inputSchema: exports_external.object({ id: exports_external.string().describe("Signoff ID") }),
19144
+ execute: async (client, input) => unwrap2(await client.signoffs.find(input.id))
19145
+ }),
19146
+ devpad_signoffs_decide: define_tool({
19147
+ name: "devpad_signoffs_decide",
19148
+ description: "Decide a signoff checkpoint (approved | changes_requested). Human-only — an api-channel key gets 403. Approving a doc_version subject is vetoed by any open blocking annotation thread.",
19149
+ inputSchema: decide_checkpoint_request.extend({ id: exports_external.string().describe("Signoff ID") }),
19150
+ execute: async (client, input) => {
19151
+ const { id: id2, ...rest } = input;
19152
+ return unwrap2(await client.signoffs.decide(id2, rest));
19153
+ }
18699
19154
  })
18700
19155
  };
18701
19156
  var toolNames = Object.keys(tools);
@@ -19325,12 +19780,8 @@ function handleHttpResponse2(response) {
19325
19780
  throw new AuthenticationError2("Invalid or expired API key");
19326
19781
  case HTTP_STATUS2.NOT_FOUND:
19327
19782
  throw new ApiError2("Resource not found", { statusCode: HTTP_STATUS2.NOT_FOUND });
19328
- case HTTP_STATUS2.BAD_REQUEST:
19329
- break;
19330
19783
  default:
19331
- if (!response.ok) {
19332
- throw new ApiError2(`Request failed: ${response.statusText}`, { statusCode: response.status });
19333
- }
19784
+ break;
19334
19785
  }
19335
19786
  }
19336
19787
  async function handleResponseError2(response) {
@@ -19341,11 +19792,13 @@ async function handleResponseError2(response) {
19341
19792
  const raw = JSON.parse(errorText);
19342
19793
  parsedError = raw;
19343
19794
  } catch {}
19344
- if (response.status === HTTP_STATUS2.BAD_REQUEST && parsedError?.error?.name === "ZodError") {
19345
- const zodErrorDetails = parsedError.error.issues ? JSON.stringify(parsedError.error) : errorMessage;
19795
+ const structuredError = typeof parsedError?.error === "object" ? parsedError.error : undefined;
19796
+ if (response.status === HTTP_STATUS2.BAD_REQUEST && structuredError?.name === "ZodError") {
19797
+ const zodErrorDetails = structuredError.issues ? JSON.stringify(structuredError) : errorMessage;
19346
19798
  throw new ValidationError2(zodErrorDetails);
19347
19799
  }
19348
- throw new ApiError2(errorMessage, { statusCode: response.status });
19800
+ const message = typeof parsedError?.error === "string" ? parsedError.error : errorMessage;
19801
+ throw new ApiError2(message, { statusCode: response.status });
19349
19802
  }
19350
19803
  function handleNetworkError2(error) {
19351
19804
  const message = error instanceof Error ? error.message : "Unknown network error";
@@ -19724,6 +20177,12 @@ var ApiClient22 = class {
19724
20177
  delete: (id2) => wrap2(() => this.clients.milestones.delete(`/milestones/${id2}`)),
19725
20178
  goals: (id2) => wrap2(() => this.clients.milestones.get(`/milestones/${id2}/goals`))
19726
20179
  };
20180
+ this.hooks = {
20181
+ list: (project_id) => wrap2(() => this.clients.hooks.get("/hooks", { query: { project_id } })),
20182
+ upsert: (data) => wrap2(() => data.id ? this.clients.hooks.patch(`/hooks/${data.id}`, { body: data }) : this.clients.hooks.post("/hooks", { body: data })),
20183
+ delete: (id2) => wrap2(() => this.clients.hooks.delete(`/hooks/${id2}`)),
20184
+ deliveries: (id2, status) => wrap2(() => this.clients.hooks.get(`/hooks/${id2}/deliveries`, status ? { query: { status } } : {}))
20185
+ };
19727
20186
  this.goals = {
19728
20187
  list: () => wrap2(() => this.clients.goals.get("/goals")),
19729
20188
  find: (id2) => wrap2(() => this.clients.goals.get(`/goals/${id2}`)),
@@ -19810,6 +20269,7 @@ var ApiClient22 = class {
19810
20269
  near: (id2) => wrap2(() => this.clients.tasks.get(`/tasks/${id2}/near`)),
19811
20270
  claim: (id2, data) => wrap2(() => this.clients.tasks.post(`/tasks/${id2}/claim`, { body: data })),
19812
20271
  done: (id2, data) => wrap2(() => this.clients.tasks.post(`/tasks/${id2}/done`, { body: data })),
20272
+ advanceStage: (id2, data) => wrap2(() => this.clients.tasks.post(`/tasks/${id2}/stage`, { body: data })),
19813
20273
  link: (data) => wrap2(() => this.clients.tasks.post("/tasks/link", { body: data })),
19814
20274
  unlink: (link_id) => wrap2(() => this.clients.tasks.delete(`/tasks/link/${link_id}`)),
19815
20275
  apply: (data) => wrap2(() => this.clients.tasks.post("/tasks/apply", { body: data }))
@@ -19817,6 +20277,44 @@ var ApiClient22 = class {
19817
20277
  this.tags = {
19818
20278
  list: () => wrap2(() => this.clients.tags.get("/tags"))
19819
20279
  };
20280
+ this.docs = {
20281
+ list: (filters) => wrap2(() => {
20282
+ const query = { project_id: filters.project_id };
20283
+ if (filters.task_id)
20284
+ query.task_id = filters.task_id;
20285
+ return this.clients.docs.get("/docs", { query });
20286
+ }),
20287
+ push: (data) => wrap2(() => this.clients.docs.post("/docs", { body: data })),
20288
+ pull: (id2, version2) => wrap2(() => this.clients.docs.get(`/docs/${id2}`, version2 ? { query: { version: version2 } } : {})),
20289
+ versions: (id2) => wrap2(() => this.clients.docs.get(`/docs/${id2}/versions`)),
20290
+ createThread: (document_id, data) => wrap2(() => this.clients.docs.post(`/docs/${document_id}/threads`, { body: data })),
20291
+ replyThread: (document_id, thread_id, body) => wrap2(() => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/reply`, { body: { body } })),
20292
+ resolveThread: (document_id, thread_id) => wrap2(() => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/resolve`, {})),
20293
+ toggleBlocking: (document_id, thread_id, blocking) => wrap2(() => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/blocking`, { body: { blocking } })),
20294
+ unresolved: (filters) => wrap2(() => {
20295
+ const query = {};
20296
+ if (filters.project_id)
20297
+ query.project_id = filters.project_id;
20298
+ if (filters.document_id)
20299
+ query.document_id = filters.document_id;
20300
+ return this.clients.docs.get("/docs/annotations/unresolved", { query });
20301
+ }),
20302
+ pushInterfaceReport: (data) => wrap2(() => this.clients.docs.post("/docs/interface", { body: data })),
20303
+ interfaceStatus: (filters) => wrap2(() => {
20304
+ const query = { project_id: filters.project_id, title: filters.title };
20305
+ if (filters.task_id)
20306
+ query.task_id = filters.task_id;
20307
+ return this.clients.docs.get("/docs/interface/status", { query });
20308
+ })
20309
+ };
20310
+ this.signoffs = {
20311
+ request: (data) => wrap2(() => this.clients.signoffs.post("/signoffs", { body: data })),
20312
+ find: (id2) => wrap2(() => this.clients.signoffs.get(`/signoffs/${id2}`)),
20313
+ decide: (id2, data) => wrap2(() => this.clients.signoffs.post(`/signoffs/${id2}/decide`, { body: data }))
20314
+ };
20315
+ this.reviews = {
20316
+ pending: () => wrap2(() => this.clients.reviews.get("/reviews/pending"))
20317
+ };
19820
20318
  this.github = {
19821
20319
  repos: () => wrap2(() => this.clients.github.get("/repos")),
19822
20320
  branches: (owner, repo) => wrap2(() => this.clients.github.get(`/repos/${owner}/${repo}/branches`))
@@ -20181,7 +20679,11 @@ var ApiClient22 = class {
20181
20679
  blog: new ApiClient3({ ...clientOptions, category: "blog" }),
20182
20680
  media: new ApiClient3({ ...clientOptions, category: "media" }),
20183
20681
  pulse: new ApiClient3({ ...clientOptions, base_url: `${base_url}/pulse`, category: "pulse" }),
20184
- pipelines: new ApiClient3({ ...clientOptions, category: "pipelines" })
20682
+ pipelines: new ApiClient3({ ...clientOptions, category: "pipelines" }),
20683
+ hooks: new ApiClient3({ ...clientOptions, category: "hooks" }),
20684
+ docs: new ApiClient3({ ...clientOptions, category: "docs" }),
20685
+ signoffs: new ApiClient3({ ...clientOptions, category: "signoffs" }),
20686
+ reviews: new ApiClient3({ ...clientOptions, category: "reviews" })
20185
20687
  };
20186
20688
  }
20187
20689
  history() {
@@ -20267,6 +20769,16 @@ var milestone_by_id2 = exports_external.object({
20267
20769
  var goal_by_id2 = exports_external.object({
20268
20770
  id: exports_external.string().describe("Goal ID")
20269
20771
  });
20772
+ var hook_filters2 = exports_external.object({
20773
+ project_id: exports_external.string().describe("Project ID to list hooks for")
20774
+ });
20775
+ var hook_by_id2 = exports_external.object({
20776
+ id: exports_external.string().describe("Hook ID")
20777
+ });
20778
+ var hook_deliveries_input2 = exports_external.object({
20779
+ id: exports_external.string().describe("Hook ID"),
20780
+ status: exports_external.enum(["pending", "delivered", "failed_transient", "failed_permanent"]).optional().describe("Filter by delivery status — use failed_permanent to see the DLQ")
20781
+ });
20270
20782
  var github_branches2 = exports_external.object({
20271
20783
  owner: exports_external.string().describe("Repository owner"),
20272
20784
  repo: exports_external.string().describe("Repository name")
@@ -20364,6 +20876,30 @@ var tools2 = {
20364
20876
  finished_at: input.finished_at
20365
20877
  }))
20366
20878
  }),
20879
+ devpad_hooks_list: define_tool2({
20880
+ name: "devpad_hooks_list",
20881
+ description: "List hooks configured for a project",
20882
+ inputSchema: hook_filters2,
20883
+ execute: async (client, input) => unwrap3(await client.hooks.list(input.project_id))
20884
+ }),
20885
+ devpad_hooks_upsert: define_tool2({
20886
+ name: "devpad_hooks_upsert",
20887
+ description: "Create or update a hook (webhook/vault/pipeline action fired on matching task_event kinds). Pass 'id' to update.",
20888
+ inputSchema: upsert_hook,
20889
+ execute: async (client, input) => unwrap3(await client.hooks.upsert(input))
20890
+ }),
20891
+ devpad_hooks_delete: define_tool2({
20892
+ name: "devpad_hooks_delete",
20893
+ description: "Delete a hook",
20894
+ inputSchema: hook_by_id2,
20895
+ execute: async (client, input) => unwrap3(await client.hooks.delete(input.id))
20896
+ }),
20897
+ devpad_hooks_deliveries: define_tool2({
20898
+ name: "devpad_hooks_deliveries",
20899
+ description: "List delivery attempts for a hook, optionally filtered by status (the DLQ is status=failed_permanent)",
20900
+ inputSchema: hook_deliveries_input2,
20901
+ execute: async (client, input) => unwrap3(await client.hooks.deliveries(input.id, input.status))
20902
+ }),
20367
20903
  devpad_goals_list: define_tool2({
20368
20904
  name: "devpad_goals_list",
20369
20905
  description: "List goals for authenticated user",
@@ -20555,6 +21091,15 @@ var tools2 = {
20555
21091
  }),
20556
21092
  execute: async (client, input) => unwrap3(await client.tasks.unlink(input.id))
20557
21093
  }),
21094
+ devpad_tasks_advance_stage: define_tool2({
21095
+ name: "devpad_tasks_advance_stage",
21096
+ description: "Advance a task's SDLC stage (ideate|plan|build|review|deploy|live). Gated hops (plan->build needs an approved plan checkpoint; review->deploy needs approved types + design when a design doc exists) 409 naming what's missing unless override:true, which always succeeds but is audited.",
21097
+ inputSchema: advance_stage_request.extend({ id: exports_external.string().describe("Task ID") }),
21098
+ execute: async (client, input) => {
21099
+ const { id: id2, ...rest } = input;
21100
+ return unwrap3(await client.tasks.advanceStage(id2, rest));
21101
+ }
21102
+ }),
20558
21103
  devpad_tasks_apply: define_tool2({
20559
21104
  name: "devpad_tasks_apply",
20560
21105
  description: "Batch apply create/update/reparent/link/unlink/claim/complete ops atomically, with $0/$1… temp handles for subtree creation. Replaying the same idempotency_key returns the prior response verbatim.",
@@ -21104,6 +21649,128 @@ var tools2 = {
21104
21649
  owner_id: exports_external.string().describe("Owner ID (must match the policy's owner)")
21105
21650
  }),
21106
21651
  execute: async (client, input) => unwrap3(await client.pipelines.oidc_trust.delete(input.id, { owner_id: input.owner_id }))
21652
+ }),
21653
+ devpad_docs_list: define_tool2({
21654
+ name: "devpad_docs_list",
21655
+ description: "List documents for a project (optionally filtered to one task)",
21656
+ inputSchema: exports_external.object({
21657
+ project_id: exports_external.string().describe("Project ID"),
21658
+ task_id: exports_external.string().optional().describe("Filter to documents attached to this task")
21659
+ }),
21660
+ execute: async (client, input) => unwrap3(await client.docs.list(input))
21661
+ }),
21662
+ devpad_docs_push: define_tool2({
21663
+ name: "devpad_docs_push",
21664
+ description: "Push HTML content as a new document (omit document_id) or a new version on an existing one. HTML is sanitized server-side before storage — script/iframe/object/embed/form, event handlers, and javascript:/data: URLs never survive.",
21665
+ inputSchema: push_doc_request,
21666
+ execute: async (client, input) => unwrap3(await client.docs.push(input))
21667
+ }),
21668
+ devpad_docs_pull: define_tool2({
21669
+ name: "devpad_docs_pull",
21670
+ description: "Pull a document's content at a specific version (default: head)",
21671
+ inputSchema: exports_external.object({
21672
+ id: exports_external.string().describe("Document ID"),
21673
+ version: exports_external.string().optional().describe("Corpus version — defaults to head")
21674
+ }),
21675
+ execute: async (client, input) => unwrap3(await client.docs.pull(input.id, input.version))
21676
+ }),
21677
+ devpad_docs_versions: define_tool2({
21678
+ name: "devpad_docs_versions",
21679
+ description: "Full version history for a document, newest first (the lineage walk)",
21680
+ inputSchema: exports_external.object({
21681
+ id: exports_external.string().describe("Document ID")
21682
+ }),
21683
+ execute: async (client, input) => unwrap3(await client.docs.versions(input.id))
21684
+ }),
21685
+ devpad_annotations_create: define_tool2({
21686
+ name: "devpad_annotations_create",
21687
+ description: "Open a new annotation thread on a document, anchored to an exact quote (with prefix/suffix context + char offsets for re-anchoring across edits)",
21688
+ inputSchema: create_thread_request.extend({ document_id: exports_external.string().describe("Document ID") }),
21689
+ execute: async (client, input) => {
21690
+ const { document_id, ...rest } = input;
21691
+ return unwrap3(await client.docs.createThread(document_id, rest));
21692
+ }
21693
+ }),
21694
+ devpad_annotations_reply: define_tool2({
21695
+ name: "devpad_annotations_reply",
21696
+ description: "Reply to an existing annotation thread",
21697
+ inputSchema: exports_external.object({
21698
+ document_id: exports_external.string().describe("Document ID"),
21699
+ thread_id: exports_external.string().describe("Thread ID (from the marker JSON, not the document ID)"),
21700
+ body: exports_external.string().min(1).describe("Reply text")
21701
+ }),
21702
+ execute: async (client, input) => unwrap3(await client.docs.replyThread(input.document_id, input.thread_id, input.body))
21703
+ }),
21704
+ devpad_annotations_resolve: define_tool2({
21705
+ name: "devpad_annotations_resolve",
21706
+ description: "Mark an annotation thread resolved",
21707
+ inputSchema: exports_external.object({
21708
+ document_id: exports_external.string().describe("Document ID"),
21709
+ thread_id: exports_external.string().describe("Thread ID")
21710
+ }),
21711
+ execute: async (client, input) => unwrap3(await client.docs.resolveThread(input.document_id, input.thread_id))
21712
+ }),
21713
+ devpad_annotations_toggle_blocking: define_tool2({
21714
+ name: "devpad_annotations_toggle_blocking",
21715
+ description: "Toggle whether an annotation thread blocks approval",
21716
+ inputSchema: exports_external.object({
21717
+ document_id: exports_external.string().describe("Document ID"),
21718
+ thread_id: exports_external.string().describe("Thread ID"),
21719
+ blocking: exports_external.boolean()
21720
+ }),
21721
+ execute: async (client, input) => unwrap3(await client.docs.toggleBlocking(input.document_id, input.thread_id, input.blocking))
21722
+ }),
21723
+ devpad_interface_push: define_tool2({
21724
+ name: "devpad_interface_push",
21725
+ description: "Push already-normalized declaration text as a new interface-doc version. The server independently recomputes additive-vs-breaking against its own stored previous content and auto-approves additive diffs against an approved base.",
21726
+ inputSchema: push_interface_report_request,
21727
+ execute: async (client, input) => unwrap3(await client.docs.pushInterfaceReport(input))
21728
+ }),
21729
+ devpad_interface_status: define_tool2({
21730
+ name: "devpad_interface_status",
21731
+ description: "Get the approved/auto content_hash for an interface doc, for a client-side hash comparison (the `check` verb)",
21732
+ inputSchema: exports_external.object({
21733
+ project_id: exports_external.string().describe("Project ID"),
21734
+ task_id: exports_external.string().optional().describe("Task ID"),
21735
+ title: exports_external.string().describe("The interface document's title (package name)")
21736
+ }),
21737
+ execute: async (client, input) => unwrap3(await client.docs.interfaceStatus(input))
21738
+ }),
21739
+ devpad_reviews_pending: define_tool2({
21740
+ name: "devpad_reviews_pending",
21741
+ description: "The human's queue — one typed aggregate across pending signoff checkpoints, open blocking annotation threads, pending pipeline manual gates, and pending scanner diffs, scoped to the authenticated user",
21742
+ inputSchema: exports_external.object({}),
21743
+ execute: async (client) => unwrap3(await client.reviews.pending())
21744
+ }),
21745
+ devpad_annotations_unresolved: define_tool2({
21746
+ name: "devpad_annotations_unresolved",
21747
+ description: "List pending annotation threads (anything not resolved) for a project or a specific document",
21748
+ inputSchema: exports_external.object({
21749
+ project_id: exports_external.string().optional().describe("Project ID"),
21750
+ document_id: exports_external.string().optional().describe("Document ID")
21751
+ }),
21752
+ execute: async (client, input) => unwrap3(await client.docs.unresolved(input))
21753
+ }),
21754
+ devpad_signoffs_request: define_tool2({
21755
+ name: "devpad_signoffs_request",
21756
+ description: "Request a human signoff checkpoint — creates a pending approval node that blocks the named downstream tasks until decided",
21757
+ inputSchema: request_checkpoint_request,
21758
+ execute: async (client, input) => unwrap3(await client.signoffs.request(input))
21759
+ }),
21760
+ devpad_signoffs_get: define_tool2({
21761
+ name: "devpad_signoffs_get",
21762
+ description: "Get a signoff checkpoint's current state",
21763
+ inputSchema: exports_external.object({ id: exports_external.string().describe("Signoff ID") }),
21764
+ execute: async (client, input) => unwrap3(await client.signoffs.find(input.id))
21765
+ }),
21766
+ devpad_signoffs_decide: define_tool2({
21767
+ name: "devpad_signoffs_decide",
21768
+ description: "Decide a signoff checkpoint (approved | changes_requested). Human-only — an api-channel key gets 403. Approving a doc_version subject is vetoed by any open blocking annotation thread.",
21769
+ inputSchema: decide_checkpoint_request.extend({ id: exports_external.string().describe("Signoff ID") }),
21770
+ execute: async (client, input) => {
21771
+ const { id: id2, ...rest } = input;
21772
+ return unwrap3(await client.signoffs.decide(id2, rest));
21773
+ }
21107
21774
  })
21108
21775
  };
21109
21776
  var toolNames2 = Object.keys(tools2);
@@ -24225,6 +24892,7 @@ var api_keys2 = sqliteTable("api_keys", {
24225
24892
  name: text("name"),
24226
24893
  note: text("note"),
24227
24894
  scope: text("scope", { enum: ["devpad", "blog", "media", "pulse", "all"] }).notNull().default("all"),
24895
+ project_id: text("project_id").references(() => project2.id),
24228
24896
  enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
24229
24897
  last_used_at: text("last_used_at"),
24230
24898
  ...timestamps2(),
@@ -24244,7 +24912,8 @@ var project2 = sqliteTable("project", {
24244
24912
  link_text: text("link_text"),
24245
24913
  visibility: text("visibility", { enum: ["PUBLIC", "PRIVATE", "HIDDEN", "ARCHIVED", "DRAFT", "DELETED"] }).notNull().default("PRIVATE"),
24246
24914
  current_version: text("current_version"),
24247
- scan_branch: text("scan_branch")
24915
+ scan_branch: text("scan_branch"),
24916
+ github_autoclose: integer("github_autoclose", { mode: "boolean" }).notNull().default(false)
24248
24917
  });
24249
24918
  var ACTIONS2 = [
24250
24919
  "CREATE_TASK",
@@ -24264,7 +24933,8 @@ var ACTIONS2 = [
24264
24933
  "DELETE_MILESTONE",
24265
24934
  "CREATE_CHECKLIST",
24266
24935
  "UPDATE_CHECKLIST",
24267
- "DELETE_CHECKLIST"
24936
+ "DELETE_CHECKLIST",
24937
+ "ADVANCE_STAGE"
24268
24938
  ];
24269
24939
  var action2 = sqliteTable("action", {
24270
24940
  ...owned_entity2("action"),
@@ -24319,6 +24989,7 @@ var TASK_KINDS2 = ["task", "phase", "approval"];
24319
24989
  var COMPLETION_POLICIES2 = ["manual", "auto_children"];
24320
24990
  var COMPLETED_VIA_VALUES2 = ["user", "api", "policy"];
24321
24991
  var TASK_LINK_KINDS2 = ["blocks", "relates_to", "references", "discovered_from", "tracks_metric"];
24992
+ var SDLC_STAGES2 = ["ideate", "plan", "build", "review", "deploy", "live"];
24322
24993
  var task2 = sqliteTable("task", {
24323
24994
  ...owned_entity2("task"),
24324
24995
  title: text("title").notNull(),
@@ -24339,7 +25010,8 @@ var task2 = sqliteTable("task", {
24339
25010
  completion_policy: text("completion_policy", { enum: COMPLETION_POLICIES2 }).notNull().default("manual"),
24340
25011
  completed_via: text("completed_via", { enum: COMPLETED_VIA_VALUES2 }),
24341
25012
  claimed_by: text("claimed_by"),
24342
- claimed_at: text("claimed_at")
25013
+ claimed_at: text("claimed_at"),
25014
+ stage: text("stage", { enum: SDLC_STAGES2 })
24343
25015
  }, (table3) => [index("task_parent_id_idx").on(table3.parent_id)]);
24344
25016
  var task_link2 = sqliteTable("task_link", {
24345
25017
  ...entity3("link"),
@@ -24376,7 +25048,13 @@ var TASK_EVENT_KINDS2 = [
24376
25048
  "edge.removed",
24377
25049
  "node.children_all_done",
24378
25050
  "policy.fired",
24379
- "node.completion_stale"
25051
+ "node.completion_stale",
25052
+ "doc.pushed",
25053
+ "thread.opened",
25054
+ "thread.resolved",
25055
+ "signoff.requested",
25056
+ "signoff.decided",
25057
+ "stage.advanced"
24380
25058
  ];
24381
25059
  var TASK_EVENT_ACTORS2 = ["user", "api", "policy", "github"];
24382
25060
  var TASK_EVENT_DISPATCH_STATUSES2 = ["pending", "dispatched"];
@@ -24395,6 +25073,74 @@ var task_event2 = sqliteTable("task_event", {
24395
25073
  index("task_event_subject_id_idx").on(table3.subject_id),
24396
25074
  index("task_event_dispatch_status_idx").on(table3.dispatch_status)
24397
25075
  ]);
25076
+ var hook2 = sqliteTable("hook", {
25077
+ ...entity3("hook"),
25078
+ project_id: text("project_id").notNull().references(() => project2.id),
25079
+ enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
25080
+ trigger: text("trigger", { mode: "json" }).notNull(),
25081
+ action: text("action", { mode: "json" }).notNull()
25082
+ }, (table3) => [index("hook_project_id_idx").on(table3.project_id)]);
25083
+ var HOOK_DELIVERY_STATUSES2 = ["pending", "delivered", "failed_transient", "failed_permanent"];
25084
+ var hook_delivery2 = sqliteTable("hook_delivery", {
25085
+ id: text("id").primaryKey(),
25086
+ hook_id: text("hook_id").notNull().references(() => hook2.id),
25087
+ event_id: text("event_id").notNull(),
25088
+ status: text("status", { enum: HOOK_DELIVERY_STATUSES2 }).notNull().default("pending"),
25089
+ attempts: integer("attempts").notNull().default(0),
25090
+ last_error: text("last_error"),
25091
+ ...timestamps2()
25092
+ }, (table3) => [
25093
+ index("hook_delivery_hook_id_idx").on(table3.hook_id),
25094
+ index("hook_delivery_status_idx").on(table3.status)
25095
+ ]);
25096
+ var github_webhook_event2 = sqliteTable("github_webhook_event", {
25097
+ id: text("id").primaryKey(),
25098
+ delivery_guid: text("delivery_guid").notNull(),
25099
+ event_type: text("event_type").notNull(),
25100
+ processed_at: text("processed_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
25101
+ }, (table3) => [index("github_webhook_event_delivery_guid_idx").on(table3.delivery_guid)]);
25102
+ var DOCUMENT_KINDS2 = ["plan", "design", "interface"];
25103
+ var DOCUMENT_STATUSES2 = ["draft", "in_review", "approved"];
25104
+ var document2 = sqliteTable("document", {
25105
+ ...entity3("doc"),
25106
+ project_id: text("project_id").notNull().references(() => project2.id),
25107
+ task_id: text("task_id").references(() => task2.id),
25108
+ kind: text("kind", { enum: DOCUMENT_KINDS2 }).notNull(),
25109
+ title: text("title").notNull(),
25110
+ head_version: text("head_version"),
25111
+ status: text("status", { enum: DOCUMENT_STATUSES2 }).notNull().default("draft")
25112
+ }, (table3) => [index("document_project_id_idx").on(table3.project_id), index("document_task_id_idx").on(table3.task_id)]);
25113
+ var THREAD_STATUSES2 = ["open", "addressed", "resolved", "orphaned"];
25114
+ var annotation_thread2 = sqliteTable("annotation_thread", {
25115
+ ...id2("thread"),
25116
+ document_id: text("document_id").notNull().references(() => document2.id),
25117
+ thread_id: text("thread_id").notNull(),
25118
+ status: text("status", { enum: THREAD_STATUSES2 }).notNull().default("open"),
25119
+ blocking: int("blocking", { mode: "boolean" }).notNull().default(false),
25120
+ ...timestamps2()
25121
+ }, (table3) => [
25122
+ unique("annotation_thread_unique").on(table3.document_id, table3.thread_id),
25123
+ index("annotation_thread_document_id_idx").on(table3.document_id),
25124
+ index("annotation_thread_status_idx").on(table3.status)
25125
+ ]);
25126
+ var SIGNOFF_SUBJECT_KINDS2 = ["doc_version", "stage", "pipeline_gate"];
25127
+ var SIGNOFF_CHECKPOINTS2 = ["plan", "types", "design"];
25128
+ var SIGNOFF_DECISIONS2 = ["approved", "changes_requested", "auto"];
25129
+ var signoff2 = sqliteTable("signoff", {
25130
+ ...entity3("signoff"),
25131
+ subject_kind: text("subject_kind", { enum: SIGNOFF_SUBJECT_KINDS2 }).notNull(),
25132
+ subject_id: text("subject_id").notNull(),
25133
+ checkpoint: text("checkpoint", { enum: SIGNOFF_CHECKPOINTS2 }).notNull(),
25134
+ task_id: text("task_id").references(() => task2.id),
25135
+ decision: text("decision", { enum: SIGNOFF_DECISIONS2 }),
25136
+ decided_by: text("decided_by").references(() => user2.id),
25137
+ decided_at: text("decided_at"),
25138
+ reason: text("reason"),
25139
+ content_hash: text("content_hash")
25140
+ }, (table3) => [
25141
+ index("signoff_subject_idx").on(table3.subject_kind, table3.subject_id),
25142
+ index("signoff_task_id_idx").on(table3.task_id)
25143
+ ]);
24398
25144
  var checklist2 = sqliteTable("checklist", {
24399
25145
  ...entity3("checklist"),
24400
25146
  task_id: text("task_id").notNull().references(() => task2.id),
@@ -24588,6 +25334,13 @@ var task_rollup_relations2 = relations(task_rollup2, ({ one }) => ({
24588
25334
  var task_event_relations2 = relations(task_event2, ({ one }) => ({
24589
25335
  subject: one(task2, { fields: [task_event2.subject_id], references: [task2.id] })
24590
25336
  }));
25337
+ var hook_relations2 = relations(hook2, ({ one, many }) => ({
25338
+ project: one(project2, { fields: [hook2.project_id], references: [project2.id] }),
25339
+ deliveries: many(hook_delivery2)
25340
+ }));
25341
+ var hook_delivery_relations2 = relations(hook_delivery2, ({ one }) => ({
25342
+ hook: one(hook2, { fields: [hook_delivery2.hook_id], references: [hook2.id] })
25343
+ }));
24591
25344
  var checklist_relations2 = relations(checklist2, ({ one, many }) => ({
24592
25345
  task: one(task2, { fields: [checklist2.task_id], references: [task2.id] }),
24593
25346
  items: many(checklist_item2)
@@ -24629,6 +25382,18 @@ var pipeline_analysis_template_relations2 = relations(pipeline_analysis_template
24629
25382
  var pipeline_oidc_trust_relations2 = relations(pipeline_oidc_trust2, ({ one }) => ({
24630
25383
  owner: one(user2, { fields: [pipeline_oidc_trust2.owner_id], references: [user2.id] })
24631
25384
  }));
25385
+ var document_relations2 = relations(document2, ({ one, many }) => ({
25386
+ project: one(project2, { fields: [document2.project_id], references: [project2.id] }),
25387
+ task: one(task2, { fields: [document2.task_id], references: [task2.id] }),
25388
+ threads: many(annotation_thread2)
25389
+ }));
25390
+ var annotation_thread_relations2 = relations(annotation_thread2, ({ one }) => ({
25391
+ document: one(document2, { fields: [annotation_thread2.document_id], references: [document2.id] })
25392
+ }));
25393
+ var signoff_relations2 = relations(signoff2, ({ one }) => ({
25394
+ task: one(task2, { fields: [signoff2.task_id], references: [task2.id] }),
25395
+ decided_by_user: one(user2, { fields: [signoff2.decided_by], references: [user2.id] })
25396
+ }));
24632
25397
 
24633
25398
  // ../schema/dist/validation.js
24634
25399
  var upsert_project2 = exports_external.object({
@@ -24962,8 +25727,153 @@ var task_event_payload2 = exports_external.discriminatedUnion("kind", [
24962
25727
  exports_external.object({ kind: exports_external.literal("edge.removed"), link_kind: task_link_kind2, dst_id: exports_external.string().nullable() }),
24963
25728
  exports_external.object({ kind: exports_external.literal("node.children_all_done") }),
24964
25729
  exports_external.object({ kind: exports_external.literal("policy.fired"), policy: exports_external.enum(COMPLETION_POLICIES2) }),
24965
- exports_external.object({ kind: exports_external.literal("node.completion_stale"), child_id: exports_external.string() })
25730
+ exports_external.object({ kind: exports_external.literal("node.completion_stale"), child_id: exports_external.string() }),
25731
+ exports_external.object({ kind: exports_external.literal("doc.pushed"), document_id: exports_external.string(), version: exports_external.string() }),
25732
+ exports_external.object({ kind: exports_external.literal("thread.opened"), document_id: exports_external.string(), thread_id: exports_external.string() }),
25733
+ exports_external.object({ kind: exports_external.literal("thread.resolved"), document_id: exports_external.string(), thread_id: exports_external.string() }),
25734
+ exports_external.object({
25735
+ kind: exports_external.literal("signoff.requested"),
25736
+ subject_kind: exports_external.enum(SIGNOFF_SUBJECT_KINDS2),
25737
+ subject_id: exports_external.string(),
25738
+ checkpoint: exports_external.enum(SIGNOFF_CHECKPOINTS2)
25739
+ }),
25740
+ exports_external.object({
25741
+ kind: exports_external.literal("signoff.decided"),
25742
+ subject_kind: exports_external.enum(SIGNOFF_SUBJECT_KINDS2),
25743
+ subject_id: exports_external.string(),
25744
+ checkpoint: exports_external.enum(SIGNOFF_CHECKPOINTS2),
25745
+ decision: exports_external.enum(SIGNOFF_DECISIONS2)
25746
+ }),
25747
+ exports_external.object({
25748
+ kind: exports_external.literal("stage.advanced"),
25749
+ from: exports_external.enum(SDLC_STAGES2).nullable(),
25750
+ to: exports_external.enum(SDLC_STAGES2),
25751
+ override: exports_external.boolean()
25752
+ })
24966
25753
  ]);
25754
+ var document_kind2 = exports_external.enum(DOCUMENT_KINDS2);
25755
+ var push_doc_request2 = exports_external.object({
25756
+ document_id: exports_external.string().optional(),
25757
+ project_id: exports_external.string(),
25758
+ task_id: exports_external.string().nullable().optional(),
25759
+ kind: document_kind2,
25760
+ title: exports_external.string().min(1),
25761
+ html: exports_external.string()
25762
+ });
25763
+ var thread_anchor2 = exports_external.object({
25764
+ quote: exports_external.string().min(1),
25765
+ prefix: exports_external.string(),
25766
+ suffix: exports_external.string(),
25767
+ start: exports_external.number().int().nonnegative(),
25768
+ end: exports_external.number().int().nonnegative()
25769
+ });
25770
+ var thread_entry2 = exports_external.object({
25771
+ author: exports_external.string().min(1),
25772
+ channel: exports_external.enum(["user", "api"]),
25773
+ body: exports_external.string().min(1),
25774
+ at: exports_external.string()
25775
+ });
25776
+ var thread_status2 = exports_external.enum(THREAD_STATUSES2);
25777
+ var thread_marker2 = exports_external.object({
25778
+ id: exports_external.string().min(1),
25779
+ anchor: thread_anchor2,
25780
+ status: thread_status2,
25781
+ blocking: exports_external.boolean(),
25782
+ entries: exports_external.array(thread_entry2).min(1)
25783
+ });
25784
+ var create_thread_request2 = exports_external.object({
25785
+ quote: exports_external.string().min(1),
25786
+ prefix: exports_external.string(),
25787
+ suffix: exports_external.string(),
25788
+ start: exports_external.number().int().nonnegative(),
25789
+ end: exports_external.number().int().nonnegative(),
25790
+ body: exports_external.string().min(1),
25791
+ blocking: exports_external.boolean().optional().default(false)
25792
+ });
25793
+ var reply_thread_request2 = exports_external.object({ body: exports_external.string().min(1) });
25794
+ var toggle_blocking_request2 = exports_external.object({ blocking: exports_external.boolean() });
25795
+ var signoff_subject_kind2 = exports_external.enum(SIGNOFF_SUBJECT_KINDS2);
25796
+ var signoff_checkpoint2 = exports_external.enum(SIGNOFF_CHECKPOINTS2);
25797
+ var request_checkpoint_request2 = exports_external.object({
25798
+ project_id: exports_external.string(),
25799
+ subject_kind: signoff_subject_kind2,
25800
+ subject_id: exports_external.string(),
25801
+ checkpoint: signoff_checkpoint2,
25802
+ blocks: exports_external.array(exports_external.string()).default([])
25803
+ });
25804
+ var decide_checkpoint_request2 = exports_external.object({
25805
+ decision: exports_external.union([exports_external.literal("approved"), exports_external.literal("changes_requested")]),
25806
+ reason: exports_external.string().optional()
25807
+ });
25808
+ var sdlc_stage2 = exports_external.enum(SDLC_STAGES2);
25809
+ var advance_stage_request2 = exports_external.object({
25810
+ to: sdlc_stage2,
25811
+ override: exports_external.boolean().optional().default(false),
25812
+ reason: exports_external.string().optional()
25813
+ });
25814
+ var push_interface_report_request2 = exports_external.object({
25815
+ document_id: exports_external.string().optional(),
25816
+ project_id: exports_external.string(),
25817
+ task_id: exports_external.string().nullable().optional(),
25818
+ title: exports_external.string().min(1),
25819
+ normalized: exports_external.string()
25820
+ });
25821
+ var REVIEW_ITEM_KINDS2 = ["signoff", "annotation", "pipeline_gate", "scan_diff"];
25822
+ var review_item2 = exports_external.object({
25823
+ kind: exports_external.enum(REVIEW_ITEM_KINDS2),
25824
+ subject_id: exports_external.string(),
25825
+ title: exports_external.string(),
25826
+ project_id: exports_external.string().nullable(),
25827
+ created_at: exports_external.string(),
25828
+ path: exports_external.string()
25829
+ });
25830
+ var reviews_pending_response2 = exports_external.object({ items: exports_external.array(review_item2) });
25831
+ var hook_selector2 = exports_external.object({
25832
+ subject_kind: exports_external.enum(TASK_KINDS2).optional(),
25833
+ tag: exports_external.string().optional(),
25834
+ ancestor_id: exports_external.string().optional()
25835
+ });
25836
+ var hook_trigger2 = exports_external.object({
25837
+ kinds: exports_external.array(exports_external.enum(TASK_EVENT_KINDS2)).min(1),
25838
+ selector: hook_selector2.default({})
25839
+ });
25840
+ var hook_action_input2 = exports_external.discriminatedUnion("kind", [
25841
+ exports_external.object({ kind: exports_external.literal("webhook"), url: exports_external.string().url(), secret: exports_external.string().min(1).optional() }),
25842
+ exports_external.object({
25843
+ kind: exports_external.literal("vault"),
25844
+ scope: exports_external.string().min(1),
25845
+ op: exports_external.string().min(1),
25846
+ args: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
25847
+ }),
25848
+ exports_external.object({ kind: exports_external.literal("pipeline"), package_id: exports_external.string().min(1) })
25849
+ ]);
25850
+ var hook_action_stored2 = exports_external.discriminatedUnion("kind", [
25851
+ exports_external.object({ kind: exports_external.literal("webhook"), url: exports_external.string().url(), secret_encrypted: exports_external.string().optional() }),
25852
+ exports_external.object({
25853
+ kind: exports_external.literal("vault"),
25854
+ scope: exports_external.string().min(1),
25855
+ op: exports_external.string().min(1),
25856
+ args: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
25857
+ }),
25858
+ exports_external.object({ kind: exports_external.literal("pipeline"), package_id: exports_external.string().min(1) })
25859
+ ]);
25860
+ var hook_action_public2 = exports_external.discriminatedUnion("kind", [
25861
+ exports_external.object({ kind: exports_external.literal("webhook"), url: exports_external.string().url(), has_secret: exports_external.boolean() }),
25862
+ exports_external.object({
25863
+ kind: exports_external.literal("vault"),
25864
+ scope: exports_external.string().min(1),
25865
+ op: exports_external.string().min(1),
25866
+ args: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
25867
+ }),
25868
+ exports_external.object({ kind: exports_external.literal("pipeline"), package_id: exports_external.string().min(1) })
25869
+ ]);
25870
+ var upsert_hook2 = exports_external.object({
25871
+ id: exports_external.string().optional(),
25872
+ project_id: exports_external.string(),
25873
+ enabled: exports_external.boolean().default(true),
25874
+ trigger: hook_trigger2,
25875
+ action: hook_action_input2
25876
+ });
24967
25877
 
24968
25878
  // src/graph-commands.ts
24969
25879
  async function print_json(data) {
@@ -25048,6 +25958,15 @@ function register_graph_commands(program2, tasks, get_client) {
25048
25958
  spinner.succeed("Batch applied");
25049
25959
  await print_json(result);
25050
25960
  });
25961
+ tasks.command("stage <id> <to>").description("Advance a task's SDLC stage (ideate|plan|build|review|deploy|live). Gated hops 409 naming the missing checkpoint unless --override.").option("--override", "Bypass the gate — always succeeds but is audited").option("-r, --reason <reason>", "Reason for the override").action(async (id3, to, options) => {
25962
+ const spinner = make_spinner("Advancing stage...").start();
25963
+ const tool = getTool2("devpad_tasks_advance_stage");
25964
+ if (!tool)
25965
+ return fail_with(spinner, "Tool not found: devpad_tasks_advance_stage");
25966
+ const result = await tool.execute(get_client(), { id: id3, to, override: options.override, reason: options.reason });
25967
+ spinner.succeed(`Task ${id3} advanced to ${to}`);
25968
+ await print_json(result);
25969
+ });
25051
25970
  }
25052
25971
  function try_json_parse(text3) {
25053
25972
  try {
@@ -25057,6 +25976,575 @@ function try_json_parse(text3) {
25057
25976
  }
25058
25977
  }
25059
25978
 
25979
+ // src/interface-commands.ts
25980
+ import { execSync } from "node:child_process";
25981
+ import { existsSync as existsSync3, mkdtempSync, readFileSync as readFileSync4, readdirSync as readdirSync3 } from "node:fs";
25982
+ import { tmpdir } from "node:os";
25983
+ import path4 from "node:path";
25984
+ // ../core/src/services/docs/interface-report.ts
25985
+ var BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
25986
+ var LINE_COMMENT_RE = /\/\/.*$/gm;
25987
+ function strip_comments(content) {
25988
+ return content.replace(BLOCK_COMMENT_RE, "").replace(LINE_COMMENT_RE, "");
25989
+ }
25990
+ function canonical_line(line) {
25991
+ return line.trim().replace(/\s+/g, " ");
25992
+ }
25993
+ function normalize_declarations(files) {
25994
+ const sorted = files.toSorted((a, b) => a.path.localeCompare(b.path));
25995
+ const sections = sorted.map((file) => {
25996
+ const lines = strip_comments(file.content).split(`
25997
+ `).map(canonical_line).filter((line) => line.length > 0);
25998
+ return [`// file: ${file.path}`, ...lines].join(`
25999
+ `);
26000
+ });
26001
+ return sections.join(`
26002
+
26003
+ `);
26004
+ }
26005
+ // ../core/src/services/docs/markers.ts
26006
+ var MARKER_COMMENT_RE = new RegExp(`<!--\\s*devpad:thread:(?:begin\\s+\\S+\\s+[A-Za-z0-9+/=]+|end\\s+\\S+)\\s*-->`, "g");
26007
+ // ../core/src/services/docs/reviews.ts
26008
+ init_dist();
26009
+ // ../../node_modules/hast-util-sanitize/lib/schema.js
26010
+ var aria = ["ariaDescribedBy", "ariaLabel", "ariaLabelledBy"];
26011
+ var defaultSchema = {
26012
+ ancestors: {
26013
+ tbody: ["table"],
26014
+ td: ["table"],
26015
+ th: ["table"],
26016
+ thead: ["table"],
26017
+ tfoot: ["table"],
26018
+ tr: ["table"]
26019
+ },
26020
+ attributes: {
26021
+ a: [
26022
+ ...aria,
26023
+ "dataFootnoteBackref",
26024
+ "dataFootnoteRef",
26025
+ ["className", "data-footnote-backref"],
26026
+ "href"
26027
+ ],
26028
+ blockquote: ["cite"],
26029
+ code: [["className", /^language-./]],
26030
+ del: ["cite"],
26031
+ div: ["itemScope", "itemType"],
26032
+ dl: [...aria],
26033
+ h2: [["className", "sr-only"]],
26034
+ img: [...aria, "longDesc", "src"],
26035
+ input: [
26036
+ ["disabled", true],
26037
+ ["type", "checkbox"]
26038
+ ],
26039
+ ins: ["cite"],
26040
+ li: [["className", "task-list-item"]],
26041
+ ol: [...aria, ["className", "contains-task-list"]],
26042
+ q: ["cite"],
26043
+ section: ["dataFootnotes", ["className", "footnotes"]],
26044
+ source: ["srcSet"],
26045
+ summary: [...aria],
26046
+ table: [...aria],
26047
+ ul: [...aria, ["className", "contains-task-list"]],
26048
+ "*": [
26049
+ "abbr",
26050
+ "accept",
26051
+ "acceptCharset",
26052
+ "accessKey",
26053
+ "action",
26054
+ "align",
26055
+ "alt",
26056
+ "axis",
26057
+ "border",
26058
+ "cellPadding",
26059
+ "cellSpacing",
26060
+ "char",
26061
+ "charOff",
26062
+ "charSet",
26063
+ "checked",
26064
+ "clear",
26065
+ "colSpan",
26066
+ "color",
26067
+ "cols",
26068
+ "compact",
26069
+ "coords",
26070
+ "dateTime",
26071
+ "dir",
26072
+ "encType",
26073
+ "frame",
26074
+ "hSpace",
26075
+ "headers",
26076
+ "height",
26077
+ "hrefLang",
26078
+ "htmlFor",
26079
+ "id",
26080
+ "isMap",
26081
+ "itemProp",
26082
+ "label",
26083
+ "lang",
26084
+ "maxLength",
26085
+ "media",
26086
+ "method",
26087
+ "multiple",
26088
+ "name",
26089
+ "noHref",
26090
+ "noShade",
26091
+ "noWrap",
26092
+ "open",
26093
+ "prompt",
26094
+ "readOnly",
26095
+ "rev",
26096
+ "rowSpan",
26097
+ "rows",
26098
+ "rules",
26099
+ "scope",
26100
+ "selected",
26101
+ "shape",
26102
+ "size",
26103
+ "span",
26104
+ "start",
26105
+ "summary",
26106
+ "tabIndex",
26107
+ "title",
26108
+ "useMap",
26109
+ "vAlign",
26110
+ "value",
26111
+ "width"
26112
+ ]
26113
+ },
26114
+ clobber: ["ariaDescribedBy", "ariaLabelledBy", "id", "name"],
26115
+ clobberPrefix: "user-content-",
26116
+ protocols: {
26117
+ cite: ["http", "https"],
26118
+ href: ["http", "https", "irc", "ircs", "mailto", "xmpp"],
26119
+ longDesc: ["http", "https"],
26120
+ src: ["http", "https"]
26121
+ },
26122
+ required: {
26123
+ input: { disabled: true, type: "checkbox" }
26124
+ },
26125
+ strip: ["script"],
26126
+ tagNames: [
26127
+ "a",
26128
+ "b",
26129
+ "blockquote",
26130
+ "br",
26131
+ "code",
26132
+ "dd",
26133
+ "del",
26134
+ "details",
26135
+ "div",
26136
+ "dl",
26137
+ "dt",
26138
+ "em",
26139
+ "h1",
26140
+ "h2",
26141
+ "h3",
26142
+ "h4",
26143
+ "h5",
26144
+ "h6",
26145
+ "hr",
26146
+ "i",
26147
+ "img",
26148
+ "input",
26149
+ "ins",
26150
+ "kbd",
26151
+ "li",
26152
+ "ol",
26153
+ "p",
26154
+ "picture",
26155
+ "pre",
26156
+ "q",
26157
+ "rp",
26158
+ "rt",
26159
+ "ruby",
26160
+ "s",
26161
+ "samp",
26162
+ "section",
26163
+ "source",
26164
+ "span",
26165
+ "strike",
26166
+ "strong",
26167
+ "sub",
26168
+ "summary",
26169
+ "sup",
26170
+ "table",
26171
+ "tbody",
26172
+ "td",
26173
+ "tfoot",
26174
+ "th",
26175
+ "thead",
26176
+ "tr",
26177
+ "tt",
26178
+ "ul",
26179
+ "var"
26180
+ ]
26181
+ };
26182
+ // ../core/src/services/docs/sanitize.ts
26183
+ var schema = {
26184
+ ...defaultSchema,
26185
+ allowComments: false,
26186
+ allowDoctypes: false,
26187
+ tagNames: [...defaultSchema.tagNames ?? [], "style"],
26188
+ strip: [...defaultSchema.strip ?? [], "iframe", "object", "embed", "form"]
26189
+ };
26190
+ var TEXT_ESCAPES = {
26191
+ "&": "&amp;",
26192
+ "<": "&lt;",
26193
+ ">": "&gt;",
26194
+ '"': "&quot;",
26195
+ "'": "&#39;"
26196
+ };
26197
+ function sanitize_text(text3) {
26198
+ return text3.replace(/[&<>"']/g, (ch) => TEXT_ESCAPES[ch] ?? ch);
26199
+ }
26200
+ // ../core/src/services/docs/signoff.ts
26201
+ init_dist();
26202
+
26203
+ // ../core/src/services/errors.ts
26204
+ init_dist();
26205
+
26206
+ // ../schema/dist/errors.js
26207
+ init_dist();
26208
+ // ../core/src/services/graph/completion.ts
26209
+ init_dist();
26210
+
26211
+ // ../core/src/services/graph/graph.ts
26212
+ init_dist();
26213
+
26214
+ // ../core/src/services/graph/outbox.ts
26215
+ init_dist();
26216
+
26217
+ // ../core/src/services/graph/rollup.ts
26218
+ init_dist();
26219
+
26220
+ // ../core/src/services/docs/store.ts
26221
+ init_dist();
26222
+ init_zod();
26223
+ var DocContentSchema = exports_external.object({
26224
+ title: exports_external.string().min(1),
26225
+ html: exports_external.string()
26226
+ });
26227
+ var base_definition = define_store("devpad-docs", json_codec(DocContentSchema));
26228
+ // ../core/src/services/docs/stage.ts
26229
+ init_dist();
26230
+ // ../core/src/services/docs/threads.ts
26231
+ init_dist();
26232
+ // src/interface-commands.ts
26233
+ init_dist();
26234
+ init_zod();
26235
+ var interface_status_response = exports_external.object({
26236
+ document_id: exports_external.string().nullable(),
26237
+ approved_content_hash: exports_external.string().nullable()
26238
+ });
26239
+ async function print_json2(data) {
26240
+ const output = JSON.stringify(data, null, 2) + `
26241
+ `;
26242
+ const flushed = process.stdout.write(output);
26243
+ if (!flushed)
26244
+ await new Promise((resolve) => process.stdout.once("drain", resolve));
26245
+ }
26246
+ function build_interface_content(files, package_name) {
26247
+ return { title: package_name, html: normalize_declarations(files) };
26248
+ }
26249
+ async function compute_local_hash(content) {
26250
+ const escaped = { title: content.title, html: sanitize_text(content.html) };
26251
+ return compute_hash(new TextEncoder().encode(JSON.stringify(escaped)));
26252
+ }
26253
+ function interface_check_exit_code(local_hash, approved_hash) {
26254
+ return approved_hash !== null && local_hash === approved_hash ? 0 : 1;
26255
+ }
26256
+ function collect_dts_files(dir, root) {
26257
+ const out = [];
26258
+ for (const entry of readdirSync3(dir, { withFileTypes: true })) {
26259
+ const full = path4.join(dir, entry.name);
26260
+ if (entry.isDirectory()) {
26261
+ out.push(...collect_dts_files(full, root));
26262
+ continue;
26263
+ }
26264
+ if (entry.name.endsWith(".d.ts")) {
26265
+ out.push({ path: path4.relative(root, full), content: readFileSync4(full, "utf-8") });
26266
+ }
26267
+ }
26268
+ return out;
26269
+ }
26270
+ function collect_declaration_files(package_dir) {
26271
+ const dist_dir = path4.join(package_dir, "dist");
26272
+ if (existsSync3(dist_dir))
26273
+ return collect_dts_files(dist_dir, dist_dir);
26274
+ const tmp_dir = mkdtempSync(path4.join(tmpdir(), "devpad-interface-"));
26275
+ execSync(`bunx tsc --emitDeclarationOnly --outDir ${tmp_dir}`, { cwd: package_dir, stdio: "pipe" });
26276
+ return collect_dts_files(tmp_dir, tmp_dir);
26277
+ }
26278
+ var package_json_name = exports_external.object({ name: exports_external.string().optional() });
26279
+ function resolve_package_name(package_dir) {
26280
+ const raw = readFileSync4(path4.join(package_dir, "package.json"), "utf-8");
26281
+ const parsed = package_json_name.parse(JSON.parse(raw));
26282
+ return parsed.name ?? path4.basename(package_dir);
26283
+ }
26284
+ function register_interface_commands(program2, get_client) {
26285
+ const iface = program2.command("interface").description("Interface report — additive/breaking classification (task A4.4)");
26286
+ iface.command("push").description("Push the package's declaration output as a new interface-doc version").requiredOption("--package <dir>", "Package directory").requiredOption("-p, --project <id>", "Project ID").option("-t, --task <id>", "Task to attach").option("--document <id>", "Push a new version onto this existing interface document instead of finding one by name").action(async (options) => {
26287
+ const spinner = make_spinner("Collecting declarations...").start();
26288
+ let files;
26289
+ let package_name;
26290
+ try {
26291
+ files = collect_declaration_files(options.package);
26292
+ package_name = resolve_package_name(options.package);
26293
+ } catch (e) {
26294
+ return fail_with(spinner, `Failed to collect declarations: ${e instanceof Error ? e.message : String(e)}`);
26295
+ }
26296
+ const content = build_interface_content(files, package_name);
26297
+ let document_id = options.document;
26298
+ if (!document_id) {
26299
+ const listed = await get_client().docs.list({ project_id: options.project, task_id: options.task });
26300
+ if (!listed.ok)
26301
+ return fail_with(spinner, `Failed to list documents: ${listed.error.message}`);
26302
+ document_id = listed.value.find((d) => d.kind === "interface" && d.title === package_name)?.id;
26303
+ }
26304
+ const tool = getTool2("devpad_interface_push");
26305
+ if (!tool)
26306
+ return fail_with(spinner, "Tool not found: devpad_interface_push");
26307
+ const result = await tool.execute(get_client(), {
26308
+ document_id,
26309
+ project_id: options.project,
26310
+ task_id: options.task,
26311
+ title: content.title,
26312
+ normalized: content.html
26313
+ });
26314
+ spinner.succeed("Interface report pushed");
26315
+ await print_json2(result);
26316
+ });
26317
+ iface.command("check").description("Regenerate declarations locally and hash-compare against the approved base — exits 1 on drift").requiredOption("--package <dir>", "Package directory").requiredOption("-p, --project <id>", "Project ID").option("-t, --task <id>", "Task the interface doc is attached to").action(async (options) => {
26318
+ const spinner = make_spinner("Checking interface report...").start();
26319
+ let files;
26320
+ let package_name;
26321
+ try {
26322
+ files = collect_declaration_files(options.package);
26323
+ package_name = resolve_package_name(options.package);
26324
+ } catch (e) {
26325
+ return fail_with(spinner, `Failed to collect declarations: ${e instanceof Error ? e.message : String(e)}`);
26326
+ }
26327
+ const content = build_interface_content(files, package_name);
26328
+ const local_hash = await compute_local_hash(content);
26329
+ const tool = getTool2("devpad_interface_status");
26330
+ if (!tool)
26331
+ return fail_with(spinner, "Tool not found: devpad_interface_status");
26332
+ const raw_status = await tool.execute(get_client(), {
26333
+ project_id: options.project,
26334
+ task_id: options.task,
26335
+ title: package_name
26336
+ });
26337
+ const status = interface_status_response.parse(raw_status);
26338
+ const exit_code = interface_check_exit_code(local_hash, status.approved_content_hash);
26339
+ if (exit_code === 0) {
26340
+ spinner.succeed("Interface report matches the approved base");
26341
+ } else {
26342
+ spinner.fail("Interface report has drifted from the approved base");
26343
+ }
26344
+ await print_json2({ local_hash, approved_content_hash: status.approved_content_hash, exit_code });
26345
+ process.exit(exit_code);
26346
+ });
26347
+ }
26348
+
26349
+ // src/plans-commands.ts
26350
+ import { readFileSync as readFileSync5 } from "node:fs";
26351
+ async function print_json3(data) {
26352
+ const output = JSON.stringify(data, null, 2) + `
26353
+ `;
26354
+ const flushed = process.stdout.write(output);
26355
+ if (!flushed)
26356
+ await new Promise((resolve) => process.stdout.once("drain", resolve));
26357
+ }
26358
+ var DOCUMENT_KINDS3 = ["plan", "design", "interface"];
26359
+ function is_document_kind(value) {
26360
+ return DOCUMENT_KINDS3.includes(value);
26361
+ }
26362
+ function register_plans_commands(program2, get_client) {
26363
+ const plans = program2.command("plans").description("Push/pull docs to the corpus-backed doc store");
26364
+ plans.command("push <file>").description("Push an HTML file as a new document, or a new version onto an existing one (--document)").requiredOption("-p, --project <id>", "Project ID").option("-t, --task <id>", "Attach to a task").option("-k, --kind <kind>", "plan | design | interface (default: plan)", "plan").option("--title <title>", "Document title (default: the file name)").option("--document <id>", "Push a new version onto this existing document instead of creating one").action(async (file, options) => {
26365
+ const spinner = make_spinner("Pushing document...").start();
26366
+ if (!is_document_kind(options.kind)) {
26367
+ return fail_with(spinner, `Invalid --kind '${options.kind}' — expected plan | design | interface`);
26368
+ }
26369
+ let html;
26370
+ try {
26371
+ html = readFileSync5(file, "utf-8");
26372
+ } catch (e) {
26373
+ return fail_with(spinner, `Failed to read ${file}: ${e instanceof Error ? e.message : String(e)}`);
26374
+ }
26375
+ const tool = getTool2("devpad_docs_push");
26376
+ if (!tool)
26377
+ return fail_with(spinner, "Tool not found: devpad_docs_push");
26378
+ const result = await tool.execute(get_client(), {
26379
+ document_id: options.document,
26380
+ project_id: options.project,
26381
+ task_id: options.task,
26382
+ kind: options.kind,
26383
+ title: options.title ?? file.split("/").pop() ?? file,
26384
+ html
26385
+ });
26386
+ spinner.succeed("Document pushed");
26387
+ await print_json3(result);
26388
+ });
26389
+ plans.command("pull <document_id>").description("Pull a document's content at a specific version (default: head)").option("-v, --version <version>", "Corpus version — defaults to head").option("--annotated", "Include the decoded annotation threads (open + orphaned) alongside the content").action(async (document_id, options) => {
26390
+ const spinner = make_spinner("Pulling document...").start();
26391
+ const tool = getTool2("devpad_docs_pull");
26392
+ if (!tool)
26393
+ return fail_with(spinner, "Tool not found: devpad_docs_pull");
26394
+ const result = await tool.execute(get_client(), { id: document_id, version: options.version });
26395
+ spinner.succeed("Document pulled");
26396
+ if (options.annotated || typeof result !== "object" || result === null) {
26397
+ await print_json3(result);
26398
+ return;
26399
+ }
26400
+ const { threads: _threads, orphaned: _orphaned, ...without_threads } = result;
26401
+ await print_json3(without_threads);
26402
+ });
26403
+ plans.command("versions <document_id>").description("Full version history for a document, newest first").action(async (document_id) => {
26404
+ const spinner = make_spinner("Fetching version history...").start();
26405
+ const tool = getTool2("devpad_docs_versions");
26406
+ if (!tool)
26407
+ return fail_with(spinner, "Tool not found: devpad_docs_versions");
26408
+ const result = await tool.execute(get_client(), { id: document_id });
26409
+ spinner.succeed("Version history fetched");
26410
+ await print_json3(result);
26411
+ });
26412
+ plans.command("list").description("List documents for a project").requiredOption("-p, --project <id>", "Project ID").option("-t, --task <id>", "Filter to documents attached to this task").action(async (options) => {
26413
+ const spinner = make_spinner("Listing documents...").start();
26414
+ const tool = getTool2("devpad_docs_list");
26415
+ if (!tool)
26416
+ return fail_with(spinner, "Tool not found: devpad_docs_list");
26417
+ const result = await tool.execute(get_client(), { project_id: options.project, task_id: options.task });
26418
+ spinner.succeed("Documents listed");
26419
+ await print_json3(result);
26420
+ });
26421
+ const annotations = plans.command("annotations").description("Markers-in-doc annotation threads (task A4.2)");
26422
+ annotations.command("create <document_id>").description("Open a new annotation thread, anchored to an exact quote").requiredOption("--quote <text>", "The exact text being annotated").requiredOption("--prefix <text>", "~32 chars immediately before the quote").requiredOption("--suffix <text>", "~32 chars immediately after the quote").requiredOption("--start <n>", "Character offset of the quote's start").requiredOption("--end <n>", "Character offset of the quote's end").requiredOption("--body <text>", "The annotation's comment text").option("--blocking", "Mark this thread as blocking approval", false).action(async (document_id, options) => {
26423
+ const spinner = make_spinner("Creating annotation thread...").start();
26424
+ const tool = getTool2("devpad_annotations_create");
26425
+ if (!tool)
26426
+ return fail_with(spinner, "Tool not found: devpad_annotations_create");
26427
+ const result = await tool.execute(get_client(), {
26428
+ document_id,
26429
+ quote: options.quote,
26430
+ prefix: options.prefix,
26431
+ suffix: options.suffix,
26432
+ start: Number(options.start),
26433
+ end: Number(options.end),
26434
+ body: options.body,
26435
+ blocking: options.blocking
26436
+ });
26437
+ spinner.succeed("Annotation thread created");
26438
+ await print_json3(result);
26439
+ });
26440
+ annotations.command("reply <document_id> <thread_id>").description("Reply to an annotation thread").requiredOption("--body <text>", "Reply text").action(async (document_id, thread_id, options) => {
26441
+ const spinner = make_spinner("Replying to thread...").start();
26442
+ const tool = getTool2("devpad_annotations_reply");
26443
+ if (!tool)
26444
+ return fail_with(spinner, "Tool not found: devpad_annotations_reply");
26445
+ const result = await tool.execute(get_client(), { document_id, thread_id, body: options.body });
26446
+ spinner.succeed("Reply added");
26447
+ await print_json3(result);
26448
+ });
26449
+ annotations.command("resolve <document_id> <thread_id>").description("Mark an annotation thread resolved").action(async (document_id, thread_id) => {
26450
+ const spinner = make_spinner("Resolving thread...").start();
26451
+ const tool = getTool2("devpad_annotations_resolve");
26452
+ if (!tool)
26453
+ return fail_with(spinner, "Tool not found: devpad_annotations_resolve");
26454
+ const result = await tool.execute(get_client(), { document_id, thread_id });
26455
+ spinner.succeed("Thread resolved");
26456
+ await print_json3(result);
26457
+ });
26458
+ annotations.command("blocking <document_id> <thread_id> <blocking>").description("Toggle whether an annotation thread blocks approval (blocking: true|false)").action(async (document_id, thread_id, blocking) => {
26459
+ const spinner = make_spinner("Updating thread...").start();
26460
+ const tool = getTool2("devpad_annotations_toggle_blocking");
26461
+ if (!tool)
26462
+ return fail_with(spinner, "Tool not found: devpad_annotations_toggle_blocking");
26463
+ const result = await tool.execute(get_client(), { document_id, thread_id, blocking: blocking === "true" });
26464
+ spinner.succeed("Thread updated");
26465
+ await print_json3(result);
26466
+ });
26467
+ annotations.option("--unresolved", "List pending annotation threads (anything not resolved)").option("-p, --project <id>", "Project ID").option("-d, --document <id>", "Document ID").action(async (options) => {
26468
+ if (!options.unresolved) {
26469
+ annotations.help();
26470
+ return;
26471
+ }
26472
+ const spinner = make_spinner("Fetching unresolved annotation threads...").start();
26473
+ const tool = getTool2("devpad_annotations_unresolved");
26474
+ if (!tool)
26475
+ return fail_with(spinner, "Tool not found: devpad_annotations_unresolved");
26476
+ const result = await tool.execute(get_client(), { project_id: options.project, document_id: options.document });
26477
+ spinner.succeed("Unresolved threads fetched");
26478
+ await print_json3(result);
26479
+ });
26480
+ }
26481
+
26482
+ // src/reviews-commands.ts
26483
+ async function print_json4(data) {
26484
+ const output = JSON.stringify(data, null, 2) + `
26485
+ `;
26486
+ const flushed = process.stdout.write(output);
26487
+ if (!flushed)
26488
+ await new Promise((resolve) => process.stdout.once("drain", resolve));
26489
+ }
26490
+ function register_reviews_commands(program2, get_client) {
26491
+ const reviews2 = program2.command("reviews").description("The human's queue (task A4.6)");
26492
+ reviews2.command("pending").description("Everything waiting on a human: pending signoffs, open blocking annotation threads, pending pipeline gates, pending scanner diffs").action(async () => {
26493
+ const spinner = make_spinner("Fetching pending reviews...").start();
26494
+ const tool = getTool2("devpad_reviews_pending");
26495
+ if (!tool)
26496
+ return fail_with(spinner, "Tool not found: devpad_reviews_pending");
26497
+ const result = await tool.execute(get_client(), {});
26498
+ spinner.succeed("Pending reviews fetched");
26499
+ await print_json4(result);
26500
+ });
26501
+ }
26502
+
26503
+ // src/signoff-commands.ts
26504
+ async function print_json5(data) {
26505
+ const output = JSON.stringify(data, null, 2) + `
26506
+ `;
26507
+ const flushed = process.stdout.write(output);
26508
+ if (!flushed)
26509
+ await new Promise((resolve) => process.stdout.once("drain", resolve));
26510
+ }
26511
+ function register_signoff_commands(program2, get_client) {
26512
+ const signoffs = program2.command("signoffs").description("Human-approval checkpoints (task A4.3)");
26513
+ signoffs.command("request").description("Request a signoff checkpoint — creates a pending approval node").requiredOption("-p, --project <id>", "Project ID").requiredOption("-k, --kind <kind>", "doc_version | stage | pipeline_gate").requiredOption("-s, --subject <id>", "Subject ID (document ID, stage name, or pipeline gate ID)").requiredOption("-c, --checkpoint <checkpoint>", "plan | types | design").option("-b, --blocks <ids...>", "Downstream task IDs this checkpoint blocks", []).action(async (options) => {
26514
+ const spinner = make_spinner("Requesting checkpoint...").start();
26515
+ const tool = getTool2("devpad_signoffs_request");
26516
+ if (!tool)
26517
+ return fail_with(spinner, "Tool not found: devpad_signoffs_request");
26518
+ const result = await tool.execute(get_client(), {
26519
+ project_id: options.project,
26520
+ subject_kind: options.kind,
26521
+ subject_id: options.subject,
26522
+ checkpoint: options.checkpoint,
26523
+ blocks: options.blocks
26524
+ });
26525
+ spinner.succeed("Checkpoint requested");
26526
+ await print_json5(result);
26527
+ });
26528
+ signoffs.command("get <id>").description("Get a signoff checkpoint's current state").action(async (id3) => {
26529
+ const spinner = make_spinner("Fetching signoff...").start();
26530
+ const tool = getTool2("devpad_signoffs_get");
26531
+ if (!tool)
26532
+ return fail_with(spinner, "Tool not found: devpad_signoffs_get");
26533
+ const result = await tool.execute(get_client(), { id: id3 });
26534
+ spinner.succeed("Signoff fetched");
26535
+ await print_json5(result);
26536
+ });
26537
+ signoffs.command("decide <id> <decision>").description("Decide a signoff checkpoint (approved | changes_requested) — human-only").option("-r, --reason <reason>", "Reason for the decision").action(async (id3, decision, options) => {
26538
+ const spinner = make_spinner("Recording decision...").start();
26539
+ const tool = getTool2("devpad_signoffs_decide");
26540
+ if (!tool)
26541
+ return fail_with(spinner, "Tool not found: devpad_signoffs_decide");
26542
+ const result = await tool.execute(get_client(), { id: id3, decision, reason: options.reason });
26543
+ spinner.succeed("Decision recorded");
26544
+ await print_json5(result);
26545
+ });
26546
+ }
26547
+
25060
26548
  // src/printer.ts
25061
26549
  var make_spinner2 = (text3) => {
25062
26550
  if (process.stdout.isTTY)
@@ -25523,6 +27011,52 @@ github.command("branches <owner> <repo>").description("List branches for a GitHu
25523
27011
  handleError(error);
25524
27012
  }
25525
27013
  });
27014
+ var keysCmd = program2.command("keys").description("Manage API keys");
27015
+ keysCmd.command("list").description("List your API keys").option("-f, --format <format>", "Output format (json|table)", "json").action(async (options) => {
27016
+ const spinner = make_spinner2("Fetching API keys...").start();
27017
+ try {
27018
+ const client = getApiClient();
27019
+ const result = await client.auth.keys.list();
27020
+ if (!result.ok)
27021
+ throw new Error(result.error.message);
27022
+ spinner.succeed("API keys fetched");
27023
+ await formatOutput(result.value, options.format);
27024
+ } catch (error) {
27025
+ spinner.fail("Failed to fetch API keys");
27026
+ handleError(error);
27027
+ }
27028
+ });
27029
+ keysCmd.command("create").description("Create a new API key").option("-n, --name <name>", "Key name").option("-s, --scope <scope>", "Key scope (devpad|blog|media|pulse|all)", "devpad").option("-p, --project <id>", "Scope this key to a single project (least privilege \u2014 omit for an all-projects key)").option("-f, --format <format>", "Output format (json|table)", "json").action(async (options) => {
27030
+ const spinner = make_spinner2("Creating API key...").start();
27031
+ try {
27032
+ const client = getApiClient();
27033
+ const result = await client.auth.keys.create({
27034
+ name: options.name,
27035
+ scope: options.scope,
27036
+ project_id: options.project
27037
+ });
27038
+ if (!result.ok)
27039
+ throw new Error(result.error.message);
27040
+ spinner.succeed("API key created \u2014 save the raw key now, it won't be shown again");
27041
+ await formatOutput(result.value, options.format);
27042
+ } catch (error) {
27043
+ spinner.fail("Failed to create API key");
27044
+ handleError(error);
27045
+ }
27046
+ });
27047
+ keysCmd.command("revoke <id>").description("Revoke an API key").action(async (id3) => {
27048
+ const spinner = make_spinner2("Revoking API key...").start();
27049
+ try {
27050
+ const client = getApiClient();
27051
+ const result = await client.auth.keys.revoke(id3);
27052
+ if (!result.ok)
27053
+ throw new Error(result.error.message);
27054
+ spinner.succeed("API key revoked");
27055
+ } catch (error) {
27056
+ spinner.fail("Failed to revoke API key");
27057
+ handleError(error);
27058
+ }
27059
+ });
25526
27060
  var user3 = program2.command("user").description("User preferences and history");
25527
27061
  user3.command("history").description("Get user activity history").option("-f, --format <format>", "Output format (json|table)", "json").action(async (options) => {
25528
27062
  const spinner = make_spinner2("Fetching user history...").start();
@@ -25557,5 +27091,9 @@ user3.command("preferences").description("Update user preferences").requiredOpti
25557
27091
  }
25558
27092
  });
25559
27093
  register_graph_commands(program2, tasks, getApiClient);
27094
+ register_plans_commands(program2, getApiClient);
27095
+ register_signoff_commands(program2, getApiClient);
27096
+ register_interface_commands(program2, getApiClient);
27097
+ register_reviews_commands(program2, getApiClient);
25560
27098
  register_pipelines_commands(program2, () => getApiClient());
25561
27099
  await program2.parseAsync(process.argv);