intentdna 1.5.2 → 1.5.4

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.
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Intent DNA — MCP Transport (stdio)
3
+ *
4
+ * Minimal JSON-RPC 2.0 over stdio transport for MCP protocol.
5
+ * Zero external dependencies — implements the protocol directly.
6
+ *
7
+ * Messages are newline-delimited JSON (one JSON object per line).
8
+ */
9
+ import { createInterface } from "node:readline";
10
+ // ── Response Helpers ─────────────────────────────────────
11
+ /** Send a JSON-RPC response to stdout. */
12
+ export function sendResponse(response) {
13
+ process.stdout.write(JSON.stringify(response) + "\n");
14
+ }
15
+ /** Send a JSON-RPC success response. */
16
+ export function sendResult(id, result) {
17
+ sendResponse({ jsonrpc: "2.0", id, result });
18
+ }
19
+ /** Send a JSON-RPC error response. */
20
+ export function sendError(id, code, message) {
21
+ sendResponse({ jsonrpc: "2.0", id, error: { code, message } });
22
+ }
23
+ // ── Transport ────────────────────────────────────────────
24
+ /**
25
+ * Start reading JSON-RPC messages from stdin.
26
+ * Calls handler for each valid message.
27
+ * Exits cleanly when stdin closes.
28
+ */
29
+ export function startTransport(handler) {
30
+ const rl = createInterface({ input: process.stdin });
31
+ rl.on("line", async (line) => {
32
+ const trimmed = line.trim();
33
+ if (!trimmed)
34
+ return;
35
+ try {
36
+ const msg = JSON.parse(trimmed);
37
+ if (msg.jsonrpc !== "2.0")
38
+ return;
39
+ await handler(msg);
40
+ }
41
+ catch {
42
+ // Skip malformed messages — fail-open
43
+ }
44
+ });
45
+ rl.on("close", () => {
46
+ process.exit(0);
47
+ });
48
+ }
@@ -140,6 +140,11 @@ export interface WorkflowStepDef {
140
140
  checkpoints?: StepCheckpoint[];
141
141
  handoff?: StepHandoff;
142
142
  isolation?: "none" | "worktree" | "auto";
143
+ enforce?: {
144
+ read_only?: boolean;
145
+ relax_after_iteration?: number;
146
+ additional_write_paths?: string[];
147
+ };
143
148
  }
144
149
  /** Top-level workflow definition */
145
150
  export interface WorkflowDef {
@@ -272,6 +277,16 @@ export interface HandoffChainEntry {
272
277
  produces?: HandoffArtifact[];
273
278
  consumes?: HandoffArtifact[];
274
279
  }
280
+ /** G4: Step-level enforce rules — state-driven enforcement conditions */
281
+ export interface StepEnforceRule {
282
+ step_id: string;
283
+ /** Make step read-only (block all write tools) */
284
+ read_only?: boolean;
285
+ /** Relax scope enforcement after N iterations (rescue mode) */
286
+ relax_after_iteration?: number;
287
+ /** Additional write paths allowed beyond role scope */
288
+ additional_write_paths?: string[];
289
+ }
275
290
  /** Workflow-partitioned IR — isolates constraints per workflow */
276
291
  export interface WorkflowIR {
277
292
  workflow_name: string;
@@ -279,6 +294,7 @@ export interface WorkflowIR {
279
294
  step_checkpoints: StepCheckpointIR[];
280
295
  active_roles: string[];
281
296
  handoff_chain: HandoffChainEntry[];
297
+ step_enforce_rules?: StepEnforceRule[];
282
298
  }
283
299
  /** Record of artifacts completed by a step — used for cross-session resume */
284
300
  export interface CompletedArtifactEntry {
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "intentdna",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "Intent DNA — Declarative policy layer for AI agent behavior",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
9
9
  "dna": "dist/cli/index.js",
10
- "dna-hook": "dist/hooks/cli.js"
10
+ "dna-hook": "dist/hooks/cli.js",
11
+ "dna-mcp": "dist/mcp/index.js"
11
12
  },
12
13
  "scripts": {
13
14
  "build": "tsc && mkdir -p dist/species dist/templates && cp src/species/*.json dist/species/ && cp src/templates/*.yaml dist/templates/ && node scripts/sync-plugin-version.cjs",
@@ -165,13 +165,13 @@ hook 报错时输出人类可读的提示而非 JSON。`dna verify` 输出友好
165
165
  - [ ] 测试覆盖所有修复
166
166
 
167
167
  ### 第二阶段
168
- - [ ] .dna/state/sessions/{id}/ 目录结构
169
- - [ ] MCP server 提供 state_read/write/trace_query
170
- - [ ] MCP server 提供 compile/sync/generate
171
- - [ ] enforce 支持 WorkflowState 条件规则
172
- - [ ] 远程通信架构预留(接口定义,不实现)
168
+ - [x] .dna/state/sessions/{id}/ 目录结构
169
+ - [x] MCP server 提供 state_read/write/trace_query
170
+ - [x] MCP server 提供 compile/sync/generate
171
+ - [x] enforce 支持 WorkflowState 条件规则
172
+ - [x] 远程通信架构预留(接口定义,不实现)
173
173
 
174
174
  ### 第三阶段
175
- - [ ] dna sync 自动检测模板版本 + 提示升级
176
- - [ ] MCP server 常驻进程解决冷启动
177
- - [ ] 错误信息人类可读
175
+ - [x] dna sync 自动检测模板版本 + 提示升级
176
+ - [x] MCP server 常驻进程解决冷启动
177
+ - [x] 错误信息人类可读