@devpad/cli 2.3.5 → 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 +1275 -27
  2. package/package.json +6 -5
package/dist/index.js CHANGED
@@ -15824,7 +15824,7 @@ var require_emoji_regex = __commonJS(function(exports, module) {
15824
15824
  };
15825
15825
  });
15826
15826
 
15827
- // ../api/dist/chunk-A7B2SE7T.js
15827
+ // ../api/dist/chunk-KRYLGBPJ.js
15828
15828
  init_drizzle_orm();
15829
15829
  init_sqlite_core();
15830
15830
  init_zod();
@@ -15919,7 +15919,8 @@ var ACTIONS = [
15919
15919
  "DELETE_MILESTONE",
15920
15920
  "CREATE_CHECKLIST",
15921
15921
  "UPDATE_CHECKLIST",
15922
- "DELETE_CHECKLIST"
15922
+ "DELETE_CHECKLIST",
15923
+ "ADVANCE_STAGE"
15923
15924
  ];
15924
15925
  var action = sqliteTable("action", {
15925
15926
  ...owned_entity("action"),
@@ -15974,6 +15975,7 @@ var TASK_KINDS = ["task", "phase", "approval"];
15974
15975
  var COMPLETION_POLICIES = ["manual", "auto_children"];
15975
15976
  var COMPLETED_VIA_VALUES = ["user", "api", "policy"];
15976
15977
  var TASK_LINK_KINDS = ["blocks", "relates_to", "references", "discovered_from", "tracks_metric"];
15978
+ var SDLC_STAGES = ["ideate", "plan", "build", "review", "deploy", "live"];
15977
15979
  var task = sqliteTable("task", {
15978
15980
  ...owned_entity("task"),
15979
15981
  title: text("title").notNull(),
@@ -15994,7 +15996,8 @@ var task = sqliteTable("task", {
15994
15996
  completion_policy: text("completion_policy", { enum: COMPLETION_POLICIES }).notNull().default("manual"),
15995
15997
  completed_via: text("completed_via", { enum: COMPLETED_VIA_VALUES }),
15996
15998
  claimed_by: text("claimed_by"),
15997
- claimed_at: text("claimed_at")
15999
+ claimed_at: text("claimed_at"),
16000
+ stage: text("stage", { enum: SDLC_STAGES })
15998
16001
  }, (table3) => [index("task_parent_id_idx").on(table3.parent_id)]);
15999
16002
  var task_link = sqliteTable("task_link", {
16000
16003
  ...entity2("link"),
@@ -16031,7 +16034,13 @@ var TASK_EVENT_KINDS = [
16031
16034
  "edge.removed",
16032
16035
  "node.children_all_done",
16033
16036
  "policy.fired",
16034
- "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"
16035
16044
  ];
16036
16045
  var TASK_EVENT_ACTORS = ["user", "api", "policy", "github"];
16037
16046
  var TASK_EVENT_DISPATCH_STATUSES = ["pending", "dispatched"];
@@ -16076,6 +16085,48 @@ var github_webhook_event = sqliteTable("github_webhook_event", {
16076
16085
  event_type: text("event_type").notNull(),
16077
16086
  processed_at: text("processed_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
16078
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
+ ]);
16079
16130
  var checklist = sqliteTable("checklist", {
16080
16131
  ...entity2("checklist"),
16081
16132
  task_id: text("task_id").notNull().references(() => task.id),
@@ -16317,6 +16368,18 @@ var pipeline_analysis_template_relations = relations(pipeline_analysis_template,
16317
16368
  var pipeline_oidc_trust_relations = relations(pipeline_oidc_trust, ({ one }) => ({
16318
16369
  owner: one(user, { fields: [pipeline_oidc_trust.owner_id], references: [user.id] })
16319
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
+ }));
16320
16383
  var upsert_project = exports_external.object({
16321
16384
  id: exports_external.string().optional().nullable(),
16322
16385
  project_id: exports_external.string(),
@@ -16648,8 +16711,107 @@ var task_event_payload = exports_external.discriminatedUnion("kind", [
16648
16711
  exports_external.object({ kind: exports_external.literal("edge.removed"), link_kind: task_link_kind, dst_id: exports_external.string().nullable() }),
16649
16712
  exports_external.object({ kind: exports_external.literal("node.children_all_done") }),
16650
16713
  exports_external.object({ kind: exports_external.literal("policy.fired"), policy: exports_external.enum(COMPLETION_POLICIES) }),
16651
- 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
+ })
16652
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) });
16653
16815
  var hook_selector = exports_external.object({
16654
16816
  subject_kind: exports_external.enum(TASK_KINDS).optional(),
16655
16817
  tag: exports_external.string().optional(),
@@ -16998,12 +17160,8 @@ function handleHttpResponse(response) {
16998
17160
  throw new AuthenticationError("Invalid or expired API key");
16999
17161
  case HTTP_STATUS.NOT_FOUND:
17000
17162
  throw new ApiError("Resource not found", { statusCode: HTTP_STATUS.NOT_FOUND });
17001
- case HTTP_STATUS.BAD_REQUEST:
17002
- break;
17003
17163
  default:
17004
- if (!response.ok) {
17005
- throw new ApiError(`Request failed: ${response.statusText}`, { statusCode: response.status });
17006
- }
17164
+ break;
17007
17165
  }
17008
17166
  }
17009
17167
  async function handleResponseError(response) {
@@ -17014,11 +17172,13 @@ async function handleResponseError(response) {
17014
17172
  const raw = JSON.parse(errorText);
17015
17173
  parsedError = raw;
17016
17174
  } catch {}
17017
- if (response.status === HTTP_STATUS.BAD_REQUEST && parsedError?.error?.name === "ZodError") {
17018
- 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;
17019
17178
  throw new ValidationError(zodErrorDetails);
17020
17179
  }
17021
- 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 });
17022
17182
  }
17023
17183
  function handleNetworkError(error) {
17024
17184
  const message = error instanceof Error ? error.message : "Unknown network error";
@@ -17489,6 +17649,7 @@ var ApiClient2 = class {
17489
17649
  near: (id2) => wrap(() => this.clients.tasks.get(`/tasks/${id2}/near`)),
17490
17650
  claim: (id2, data) => wrap(() => this.clients.tasks.post(`/tasks/${id2}/claim`, { body: data })),
17491
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 })),
17492
17653
  link: (data) => wrap(() => this.clients.tasks.post("/tasks/link", { body: data })),
17493
17654
  unlink: (link_id) => wrap(() => this.clients.tasks.delete(`/tasks/link/${link_id}`)),
17494
17655
  apply: (data) => wrap(() => this.clients.tasks.post("/tasks/apply", { body: data }))
@@ -17496,6 +17657,44 @@ var ApiClient2 = class {
17496
17657
  this.tags = {
17497
17658
  list: () => wrap(() => this.clients.tags.get("/tags"))
17498
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
+ };
17499
17698
  this.github = {
17500
17699
  repos: () => wrap(() => this.clients.github.get("/repos")),
17501
17700
  branches: (owner, repo) => wrap(() => this.clients.github.get(`/repos/${owner}/${repo}/branches`))
@@ -17861,7 +18060,10 @@ var ApiClient2 = class {
17861
18060
  media: new ApiClient({ ...clientOptions, category: "media" }),
17862
18061
  pulse: new ApiClient({ ...clientOptions, base_url: `${base_url}/pulse`, category: "pulse" }),
17863
18062
  pipelines: new ApiClient({ ...clientOptions, category: "pipelines" }),
17864
- hooks: new ApiClient({ ...clientOptions, category: "hooks" })
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" })
17865
18067
  };
17866
18068
  }
17867
18069
  history() {
@@ -18269,6 +18471,15 @@ var tools = {
18269
18471
  }),
18270
18472
  execute: async (client, input) => unwrap2(await client.tasks.unlink(input.id))
18271
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
+ }),
18272
18483
  devpad_tasks_apply: define_tool({
18273
18484
  name: "devpad_tasks_apply",
18274
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.",
@@ -18818,6 +19029,128 @@ var tools = {
18818
19029
  owner_id: exports_external.string().describe("Owner ID (must match the policy's owner)")
18819
19030
  }),
18820
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
+ }
18821
19154
  })
18822
19155
  };
18823
19156
  var toolNames = Object.keys(tools);
@@ -19447,12 +19780,8 @@ function handleHttpResponse2(response) {
19447
19780
  throw new AuthenticationError2("Invalid or expired API key");
19448
19781
  case HTTP_STATUS2.NOT_FOUND:
19449
19782
  throw new ApiError2("Resource not found", { statusCode: HTTP_STATUS2.NOT_FOUND });
19450
- case HTTP_STATUS2.BAD_REQUEST:
19451
- break;
19452
19783
  default:
19453
- if (!response.ok) {
19454
- throw new ApiError2(`Request failed: ${response.statusText}`, { statusCode: response.status });
19455
- }
19784
+ break;
19456
19785
  }
19457
19786
  }
19458
19787
  async function handleResponseError2(response) {
@@ -19463,11 +19792,13 @@ async function handleResponseError2(response) {
19463
19792
  const raw = JSON.parse(errorText);
19464
19793
  parsedError = raw;
19465
19794
  } catch {}
19466
- if (response.status === HTTP_STATUS2.BAD_REQUEST && parsedError?.error?.name === "ZodError") {
19467
- 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;
19468
19798
  throw new ValidationError2(zodErrorDetails);
19469
19799
  }
19470
- 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 });
19471
19802
  }
19472
19803
  function handleNetworkError2(error) {
19473
19804
  const message = error instanceof Error ? error.message : "Unknown network error";
@@ -19938,6 +20269,7 @@ var ApiClient22 = class {
19938
20269
  near: (id2) => wrap2(() => this.clients.tasks.get(`/tasks/${id2}/near`)),
19939
20270
  claim: (id2, data) => wrap2(() => this.clients.tasks.post(`/tasks/${id2}/claim`, { body: data })),
19940
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 })),
19941
20273
  link: (data) => wrap2(() => this.clients.tasks.post("/tasks/link", { body: data })),
19942
20274
  unlink: (link_id) => wrap2(() => this.clients.tasks.delete(`/tasks/link/${link_id}`)),
19943
20275
  apply: (data) => wrap2(() => this.clients.tasks.post("/tasks/apply", { body: data }))
@@ -19945,6 +20277,44 @@ var ApiClient22 = class {
19945
20277
  this.tags = {
19946
20278
  list: () => wrap2(() => this.clients.tags.get("/tags"))
19947
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
+ };
19948
20318
  this.github = {
19949
20319
  repos: () => wrap2(() => this.clients.github.get("/repos")),
19950
20320
  branches: (owner, repo) => wrap2(() => this.clients.github.get(`/repos/${owner}/${repo}/branches`))
@@ -20310,7 +20680,10 @@ var ApiClient22 = class {
20310
20680
  media: new ApiClient3({ ...clientOptions, category: "media" }),
20311
20681
  pulse: new ApiClient3({ ...clientOptions, base_url: `${base_url}/pulse`, category: "pulse" }),
20312
20682
  pipelines: new ApiClient3({ ...clientOptions, category: "pipelines" }),
20313
- hooks: new ApiClient3({ ...clientOptions, category: "hooks" })
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" })
20314
20687
  };
20315
20688
  }
20316
20689
  history() {
@@ -20718,6 +21091,15 @@ var tools2 = {
20718
21091
  }),
20719
21092
  execute: async (client, input) => unwrap3(await client.tasks.unlink(input.id))
20720
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
+ }),
20721
21103
  devpad_tasks_apply: define_tool2({
20722
21104
  name: "devpad_tasks_apply",
20723
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.",
@@ -21267,6 +21649,128 @@ var tools2 = {
21267
21649
  owner_id: exports_external.string().describe("Owner ID (must match the policy's owner)")
21268
21650
  }),
21269
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
+ }
21270
21774
  })
21271
21775
  };
21272
21776
  var toolNames2 = Object.keys(tools2);
@@ -24429,7 +24933,8 @@ var ACTIONS2 = [
24429
24933
  "DELETE_MILESTONE",
24430
24934
  "CREATE_CHECKLIST",
24431
24935
  "UPDATE_CHECKLIST",
24432
- "DELETE_CHECKLIST"
24936
+ "DELETE_CHECKLIST",
24937
+ "ADVANCE_STAGE"
24433
24938
  ];
24434
24939
  var action2 = sqliteTable("action", {
24435
24940
  ...owned_entity2("action"),
@@ -24484,6 +24989,7 @@ var TASK_KINDS2 = ["task", "phase", "approval"];
24484
24989
  var COMPLETION_POLICIES2 = ["manual", "auto_children"];
24485
24990
  var COMPLETED_VIA_VALUES2 = ["user", "api", "policy"];
24486
24991
  var TASK_LINK_KINDS2 = ["blocks", "relates_to", "references", "discovered_from", "tracks_metric"];
24992
+ var SDLC_STAGES2 = ["ideate", "plan", "build", "review", "deploy", "live"];
24487
24993
  var task2 = sqliteTable("task", {
24488
24994
  ...owned_entity2("task"),
24489
24995
  title: text("title").notNull(),
@@ -24504,7 +25010,8 @@ var task2 = sqliteTable("task", {
24504
25010
  completion_policy: text("completion_policy", { enum: COMPLETION_POLICIES2 }).notNull().default("manual"),
24505
25011
  completed_via: text("completed_via", { enum: COMPLETED_VIA_VALUES2 }),
24506
25012
  claimed_by: text("claimed_by"),
24507
- claimed_at: text("claimed_at")
25013
+ claimed_at: text("claimed_at"),
25014
+ stage: text("stage", { enum: SDLC_STAGES2 })
24508
25015
  }, (table3) => [index("task_parent_id_idx").on(table3.parent_id)]);
24509
25016
  var task_link2 = sqliteTable("task_link", {
24510
25017
  ...entity3("link"),
@@ -24541,7 +25048,13 @@ var TASK_EVENT_KINDS2 = [
24541
25048
  "edge.removed",
24542
25049
  "node.children_all_done",
24543
25050
  "policy.fired",
24544
- "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"
24545
25058
  ];
24546
25059
  var TASK_EVENT_ACTORS2 = ["user", "api", "policy", "github"];
24547
25060
  var TASK_EVENT_DISPATCH_STATUSES2 = ["pending", "dispatched"];
@@ -24586,6 +25099,48 @@ var github_webhook_event2 = sqliteTable("github_webhook_event", {
24586
25099
  event_type: text("event_type").notNull(),
24587
25100
  processed_at: text("processed_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
24588
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
+ ]);
24589
25144
  var checklist2 = sqliteTable("checklist", {
24590
25145
  ...entity3("checklist"),
24591
25146
  task_id: text("task_id").notNull().references(() => task2.id),
@@ -24827,6 +25382,18 @@ var pipeline_analysis_template_relations2 = relations(pipeline_analysis_template
24827
25382
  var pipeline_oidc_trust_relations2 = relations(pipeline_oidc_trust2, ({ one }) => ({
24828
25383
  owner: one(user2, { fields: [pipeline_oidc_trust2.owner_id], references: [user2.id] })
24829
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
+ }));
24830
25397
 
24831
25398
  // ../schema/dist/validation.js
24832
25399
  var upsert_project2 = exports_external.object({
@@ -25160,8 +25727,107 @@ var task_event_payload2 = exports_external.discriminatedUnion("kind", [
25160
25727
  exports_external.object({ kind: exports_external.literal("edge.removed"), link_kind: task_link_kind2, dst_id: exports_external.string().nullable() }),
25161
25728
  exports_external.object({ kind: exports_external.literal("node.children_all_done") }),
25162
25729
  exports_external.object({ kind: exports_external.literal("policy.fired"), policy: exports_external.enum(COMPLETION_POLICIES2) }),
25163
- 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
+ })
25164
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) });
25165
25831
  var hook_selector2 = exports_external.object({
25166
25832
  subject_kind: exports_external.enum(TASK_KINDS2).optional(),
25167
25833
  tag: exports_external.string().optional(),
@@ -25292,6 +25958,15 @@ function register_graph_commands(program2, tasks, get_client) {
25292
25958
  spinner.succeed("Batch applied");
25293
25959
  await print_json(result);
25294
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
+ });
25295
25970
  }
25296
25971
  function try_json_parse(text3) {
25297
25972
  try {
@@ -25301,6 +25976,575 @@ function try_json_parse(text3) {
25301
25976
  }
25302
25977
  }
25303
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
+
25304
26548
  // src/printer.ts
25305
26549
  var make_spinner2 = (text3) => {
25306
26550
  if (process.stdout.isTTY)
@@ -25847,5 +27091,9 @@ user3.command("preferences").description("Update user preferences").requiredOpti
25847
27091
  }
25848
27092
  });
25849
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);
25850
27098
  register_pipelines_commands(program2, () => getApiClient());
25851
27099
  await program2.parseAsync(process.argv);