@workflow-cannon/workspace-kit 0.17.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +23 -9
  2. package/dist/cli/doctor-planning-issues.js +3 -22
  3. package/dist/cli/run-command.js +22 -38
  4. package/dist/cli.js +95 -4
  5. package/dist/contracts/command-manifest.d.ts +17 -0
  6. package/dist/contracts/command-manifest.js +1 -0
  7. package/dist/contracts/index.d.ts +1 -1
  8. package/dist/contracts/module-contract.d.ts +12 -11
  9. package/dist/core/agent-instruction-surface.d.ts +33 -0
  10. package/dist/core/agent-instruction-surface.js +46 -0
  11. package/dist/core/config-cli.js +13 -17
  12. package/dist/core/config-metadata.js +101 -2
  13. package/dist/core/index.d.ts +4 -1
  14. package/dist/core/index.js +3 -0
  15. package/dist/core/module-command-router.js +19 -1
  16. package/dist/core/module-registry-resolve.d.ts +27 -0
  17. package/dist/core/module-registry-resolve.js +91 -0
  18. package/dist/core/module-registry.d.ts +14 -0
  19. package/dist/core/module-registry.js +57 -0
  20. package/dist/core/planning/build-plan-session-file.d.ts +29 -0
  21. package/dist/core/planning/build-plan-session-file.js +58 -0
  22. package/dist/core/planning/index.d.ts +17 -0
  23. package/dist/core/planning/index.js +15 -0
  24. package/dist/core/policy.js +18 -8
  25. package/dist/core/state/unified-state-db.d.ts +21 -0
  26. package/dist/core/state/unified-state-db.js +80 -0
  27. package/dist/core/workspace-kit-config.js +13 -1
  28. package/dist/modules/agent-behavior/builtins.d.ts +3 -0
  29. package/dist/modules/agent-behavior/builtins.js +71 -0
  30. package/dist/modules/agent-behavior/explain.d.ts +6 -0
  31. package/dist/modules/agent-behavior/explain.js +46 -0
  32. package/dist/modules/agent-behavior/index.d.ts +4 -0
  33. package/dist/modules/agent-behavior/index.js +461 -0
  34. package/dist/modules/agent-behavior/interview-session-file.d.ts +9 -0
  35. package/dist/modules/agent-behavior/interview-session-file.js +43 -0
  36. package/dist/modules/agent-behavior/interview.d.ts +13 -0
  37. package/dist/modules/agent-behavior/interview.js +88 -0
  38. package/dist/modules/agent-behavior/persistence.d.ts +6 -0
  39. package/dist/modules/agent-behavior/persistence.js +89 -0
  40. package/dist/modules/agent-behavior/store.d.ts +34 -0
  41. package/dist/modules/agent-behavior/store.js +119 -0
  42. package/dist/modules/agent-behavior/types.d.ts +28 -0
  43. package/dist/modules/agent-behavior/types.js +1 -0
  44. package/dist/modules/agent-behavior/validate.d.ts +11 -0
  45. package/dist/modules/agent-behavior/validate.js +123 -0
  46. package/dist/modules/approvals/index.js +54 -51
  47. package/dist/modules/approvals/policy-sensitive-commands.d.ts +4 -0
  48. package/dist/modules/approvals/policy-sensitive-commands.js +4 -0
  49. package/dist/modules/approvals/review-runtime.js +1 -2
  50. package/dist/modules/documentation/index.js +47 -45
  51. package/dist/modules/documentation/normalizer.d.ts +3 -0
  52. package/dist/modules/documentation/normalizer.js +171 -0
  53. package/dist/modules/documentation/parser.d.ts +7 -0
  54. package/dist/modules/documentation/parser.js +39 -0
  55. package/dist/modules/documentation/policy-sensitive-commands.d.ts +5 -0
  56. package/dist/modules/documentation/policy-sensitive-commands.js +8 -0
  57. package/dist/modules/documentation/renderer.d.ts +23 -0
  58. package/dist/modules/documentation/renderer.js +105 -0
  59. package/dist/modules/documentation/runtime-batch.d.ts +10 -0
  60. package/dist/modules/documentation/runtime-batch.js +67 -0
  61. package/dist/modules/documentation/runtime-config.d.ts +11 -0
  62. package/dist/modules/documentation/runtime-config.js +54 -0
  63. package/dist/modules/documentation/runtime-render-support.d.ts +8 -0
  64. package/dist/modules/documentation/runtime-render-support.js +36 -0
  65. package/dist/modules/documentation/runtime.js +22 -510
  66. package/dist/modules/documentation/types.d.ts +182 -0
  67. package/dist/modules/documentation/validator.d.ts +8 -0
  68. package/dist/modules/documentation/validator.js +234 -0
  69. package/dist/modules/documentation/view-models.d.ts +3 -0
  70. package/dist/modules/documentation/view-models.js +124 -0
  71. package/dist/modules/improvement/generate-recommendations-runtime.js +3 -3
  72. package/dist/modules/improvement/improvement-state.d.ts +2 -2
  73. package/dist/modules/improvement/improvement-state.js +52 -23
  74. package/dist/modules/improvement/index.js +140 -138
  75. package/dist/modules/improvement/ingest.d.ts +1 -1
  76. package/dist/modules/improvement/policy-sensitive-commands.d.ts +4 -0
  77. package/dist/modules/improvement/policy-sensitive-commands.js +7 -0
  78. package/dist/modules/index.d.ts +6 -0
  79. package/dist/modules/index.js +17 -0
  80. package/dist/modules/planning/artifact.d.ts +19 -0
  81. package/dist/modules/planning/artifact.js +72 -0
  82. package/dist/modules/planning/index.js +605 -6
  83. package/dist/modules/planning/question-engine.d.ts +25 -0
  84. package/dist/modules/planning/question-engine.js +284 -0
  85. package/dist/modules/planning/types.d.ts +9 -0
  86. package/dist/modules/planning/types.js +39 -0
  87. package/dist/modules/task-engine/doctor-planning-persistence.js +21 -13
  88. package/dist/modules/task-engine/index.d.ts +1 -2
  89. package/dist/modules/task-engine/index.js +1 -1143
  90. package/dist/modules/task-engine/migrate-task-persistence-runtime.js +31 -4
  91. package/dist/modules/task-engine/migrate-wishlist-intake-runtime.d.ts +2 -0
  92. package/dist/modules/task-engine/migrate-wishlist-intake-runtime.js +146 -0
  93. package/dist/modules/task-engine/planning-open.d.ts +2 -9
  94. package/dist/modules/task-engine/planning-open.js +4 -15
  95. package/dist/modules/task-engine/policy-sensitive-commands.d.ts +5 -0
  96. package/dist/modules/task-engine/policy-sensitive-commands.js +5 -0
  97. package/dist/modules/task-engine/sqlite-dual-planning.d.ts +11 -2
  98. package/dist/modules/task-engine/sqlite-dual-planning.js +134 -28
  99. package/dist/modules/task-engine/strict-task-validation.js +3 -0
  100. package/dist/modules/task-engine/suggestions.js +2 -1
  101. package/dist/modules/task-engine/task-engine-internal.d.ts +2 -0
  102. package/dist/modules/task-engine/task-engine-internal.js +1304 -0
  103. package/dist/modules/task-engine/task-type-validation.js +40 -0
  104. package/dist/modules/task-engine/wishlist-intake.d.ts +22 -0
  105. package/dist/modules/task-engine/wishlist-intake.js +180 -0
  106. package/dist/modules/task-engine/wishlist-validation.d.ts +4 -0
  107. package/dist/modules/task-engine/wishlist-validation.js +19 -0
  108. package/dist/modules/workspace-config/index.js +9 -11
  109. package/package.json +2 -2
  110. package/schemas/agent-behavior-profile.schema.json +52 -0
  111. package/schemas/task-engine-run-contracts.schema.json +80 -5
  112. package/src/modules/documentation/README.md +16 -25
  113. package/src/modules/documentation/RULES.md +9 -9
  114. package/src/modules/documentation/index.ts +54 -49
  115. package/src/modules/documentation/instructions/document-project.md +6 -6
  116. package/src/modules/documentation/instructions/generate-document.md +4 -4
  117. package/src/modules/documentation/normalizer.ts +187 -0
  118. package/src/modules/documentation/parser.ts +41 -0
  119. package/src/modules/documentation/policy-sensitive-commands.ts +8 -0
  120. package/src/modules/documentation/renderer.ts +121 -0
  121. package/src/modules/documentation/runtime-batch.ts +74 -0
  122. package/src/modules/documentation/runtime-config.ts +68 -0
  123. package/src/modules/documentation/runtime-render-support.ts +39 -0
  124. package/src/modules/documentation/runtime.ts +28 -600
  125. package/src/modules/documentation/schemas/documentation-schema.md +37 -54
  126. package/src/modules/documentation/types.ts +228 -0
  127. package/src/modules/documentation/validator.ts +247 -0
  128. package/src/modules/documentation/view-models.ts +132 -0
  129. package/src/modules/documentation/views/agents.view.yaml +18 -0
  130. package/src/modules/documentation/views/architecture.view.yaml +18 -0
  131. package/src/modules/documentation/views/principles.view.yaml +18 -0
  132. package/src/modules/documentation/views/readme.view.yaml +18 -0
  133. package/src/modules/documentation/views/releasing.view.yaml +18 -0
  134. package/src/modules/documentation/views/roadmap.view.yaml +18 -0
  135. package/src/modules/documentation/views/runbooks-consumer-cadence.view.yaml +18 -0
  136. package/src/modules/documentation/views/runbooks-parity-validation-flow.view.yaml +18 -0
  137. package/src/modules/documentation/views/runbooks-release-channels.view.yaml +18 -0
  138. package/src/modules/documentation/views/security.view.yaml +18 -0
  139. package/src/modules/documentation/views/support.view.yaml +18 -0
  140. package/src/modules/documentation/views/terms.view.yaml +18 -0
  141. package/src/modules/documentation/views/workbooks-phase2-config-policy-workbook.view.yaml +18 -0
  142. package/src/modules/documentation/views/workbooks-task-engine-workbook.view.yaml +18 -0
  143. package/src/modules/documentation/views/workbooks-transcript-automation-baseline.view.yaml +18 -0
  144. package/src/modules/documentation/state.md +0 -8
@@ -0,0 +1,80 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import Database from "better-sqlite3";
4
+ const DDL = `
5
+ CREATE TABLE IF NOT EXISTS workspace_module_state (
6
+ module_id TEXT PRIMARY KEY,
7
+ state_schema_version INTEGER NOT NULL,
8
+ state_json TEXT NOT NULL,
9
+ updated_at TEXT NOT NULL
10
+ );
11
+ `;
12
+ export class UnifiedStateDb {
13
+ db = null;
14
+ dbPath;
15
+ exportSnapshotPath;
16
+ constructor(workspacePath, databaseRelativePath, options) {
17
+ this.dbPath = path.resolve(workspacePath, databaseRelativePath);
18
+ this.exportSnapshotPath = options?.exportSnapshotRelativePath
19
+ ? path.resolve(workspacePath, options.exportSnapshotRelativePath)
20
+ : null;
21
+ }
22
+ ensureDb() {
23
+ if (this.db)
24
+ return this.db;
25
+ fs.mkdirSync(path.dirname(this.dbPath), { recursive: true });
26
+ this.db = new Database(this.dbPath);
27
+ this.db.pragma("journal_mode = WAL");
28
+ this.db.exec(DDL);
29
+ return this.db;
30
+ }
31
+ getModuleState(moduleId) {
32
+ const db = this.ensureDb();
33
+ const row = db
34
+ .prepare("SELECT module_id, state_schema_version, state_json, updated_at FROM workspace_module_state WHERE module_id = ?")
35
+ .get(moduleId);
36
+ if (!row)
37
+ return null;
38
+ return {
39
+ moduleId: row.module_id,
40
+ stateSchemaVersion: row.state_schema_version,
41
+ state: JSON.parse(row.state_json),
42
+ updatedAt: row.updated_at
43
+ };
44
+ }
45
+ setModuleState(moduleId, stateSchemaVersion, state) {
46
+ const db = this.ensureDb();
47
+ const updatedAt = new Date().toISOString();
48
+ db.prepare(`INSERT INTO workspace_module_state (module_id, state_schema_version, state_json, updated_at)
49
+ VALUES (?, ?, ?, ?)
50
+ ON CONFLICT(module_id) DO UPDATE SET
51
+ state_schema_version=excluded.state_schema_version,
52
+ state_json=excluded.state_json,
53
+ updated_at=excluded.updated_at`).run(moduleId, stateSchemaVersion, JSON.stringify(state), updatedAt);
54
+ this.maybeExportSnapshot();
55
+ }
56
+ listModuleStates() {
57
+ const db = this.ensureDb();
58
+ const rows = db
59
+ .prepare("SELECT module_id, state_schema_version, state_json, updated_at FROM workspace_module_state ORDER BY module_id ASC")
60
+ .all();
61
+ return rows.map((row) => ({
62
+ moduleId: row.module_id,
63
+ stateSchemaVersion: row.state_schema_version,
64
+ state: JSON.parse(row.state_json),
65
+ updatedAt: row.updated_at
66
+ }));
67
+ }
68
+ maybeExportSnapshot() {
69
+ if (!this.exportSnapshotPath)
70
+ return;
71
+ const snapshot = {
72
+ schemaVersion: 1,
73
+ exportedAt: new Date().toISOString(),
74
+ dbPath: this.dbPath,
75
+ modules: this.listModuleStates()
76
+ };
77
+ fs.mkdirSync(path.dirname(this.exportSnapshotPath), { recursive: true });
78
+ fs.writeFileSync(this.exportSnapshotPath, JSON.stringify(snapshot, null, 2) + "\n", "utf8");
79
+ }
80
+ }
@@ -10,6 +10,14 @@ export function getProjectConfigPath(workspacePath) {
10
10
  /** Built-in defaults (lowest layer). */
11
11
  export const KIT_CONFIG_DEFAULTS = {
12
12
  core: {},
13
+ /**
14
+ * Module enablement: `enabled` whitelist (non-empty replaces default-by-flag set), then `disabled` subtracts.
15
+ * Empty arrays = no effect (all modules use registration.enabledByDefault).
16
+ */
17
+ modules: {
18
+ enabled: [],
19
+ disabled: []
20
+ },
13
21
  tasks: {
14
22
  storeRelativePath: ".workspace-kit/tasks/state.json",
15
23
  strictValidation: false
@@ -46,7 +54,11 @@ export const KIT_CONFIG_DEFAULTS = {
46
54
  */
47
55
  export const MODULE_CONFIG_CONTRIBUTIONS = {
48
56
  approvals: {},
49
- planning: {}
57
+ planning: {
58
+ defaultQuestionDepth: "adaptive",
59
+ hardBlockCriticalUnknowns: true,
60
+ rulePacks: {}
61
+ }
50
62
  };
51
63
  export function deepMerge(target, source) {
52
64
  const out = { ...target };
@@ -0,0 +1,3 @@
1
+ import { type BehaviorProfile } from "./types.js";
2
+ export declare const DEFAULT_BUILTIN_PROFILE_ID = "builtin:balanced";
3
+ export declare const BUILTIN_PROFILES: Record<string, BehaviorProfile>;
@@ -0,0 +1,71 @@
1
+ import { BEHAVIOR_PROFILE_SCHEMA_VERSION } from "./types.js";
2
+ export const DEFAULT_BUILTIN_PROFILE_ID = "builtin:balanced";
3
+ const nowMeta = () => ({
4
+ source: "builtin",
5
+ createdAt: new Date().toISOString()
6
+ });
7
+ export const BUILTIN_PROFILES = {
8
+ "builtin:cautious": {
9
+ schemaVersion: BEHAVIOR_PROFILE_SCHEMA_VERSION,
10
+ id: "builtin:cautious",
11
+ label: "Cautious",
12
+ summary: "Prefer small steps, frequent check-ins, and explicit confirmation before larger edits.",
13
+ dimensions: {
14
+ deliberationDepth: "high",
15
+ changeAppetite: "conservative",
16
+ checkInFrequency: "often",
17
+ explanationVerbosity: "verbose",
18
+ explorationStyle: "linear",
19
+ ambiguityHandling: "ask"
20
+ },
21
+ interactionNotes: "Surface risks early; default to the smallest reversible change.",
22
+ metadata: nowMeta()
23
+ },
24
+ "builtin:balanced": {
25
+ schemaVersion: BEHAVIOR_PROFILE_SCHEMA_VERSION,
26
+ id: "builtin:balanced",
27
+ label: "Balanced",
28
+ summary: "Default collaboration: clear reasoning, normal autonomy when intent is clear.",
29
+ dimensions: {
30
+ deliberationDepth: "medium",
31
+ changeAppetite: "balanced",
32
+ checkInFrequency: "normal",
33
+ explanationVerbosity: "normal",
34
+ explorationStyle: "linear",
35
+ ambiguityHandling: "ask"
36
+ },
37
+ metadata: nowMeta()
38
+ },
39
+ "builtin:calculated": {
40
+ schemaVersion: BEHAVIOR_PROFILE_SCHEMA_VERSION,
41
+ id: "builtin:calculated",
42
+ label: "Calculated",
43
+ summary: "Structured analysis and explicit tradeoffs before acting; still respects governance.",
44
+ dimensions: {
45
+ deliberationDepth: "high",
46
+ changeAppetite: "balanced",
47
+ checkInFrequency: "normal",
48
+ explanationVerbosity: "verbose",
49
+ explorationStyle: "linear",
50
+ ambiguityHandling: "ask"
51
+ },
52
+ interactionNotes: "Lay out options with pros/cons; prefer evidence-backed recommendations.",
53
+ metadata: nowMeta()
54
+ },
55
+ "builtin:experimental": {
56
+ schemaVersion: BEHAVIOR_PROFILE_SCHEMA_VERSION,
57
+ id: "builtin:experimental",
58
+ label: "Experimental",
59
+ summary: "Try alternatives and parallel approaches in low-risk areas; still obey policy gates.",
60
+ dimensions: {
61
+ deliberationDepth: "medium",
62
+ changeAppetite: "bold",
63
+ checkInFrequency: "normal",
64
+ explanationVerbosity: "normal",
65
+ explorationStyle: "parallel",
66
+ ambiguityHandling: "decide"
67
+ },
68
+ interactionNotes: "Experimental does not mean skipping tests, approvals, or PRINCIPLES—only style of exploration.",
69
+ metadata: nowMeta()
70
+ }
71
+ };
@@ -0,0 +1,6 @@
1
+ import type { BehaviorProfile } from "./types.js";
2
+ export declare function summarizeProfileMarkdown(profile: BehaviorProfile): string;
3
+ export declare function diffProfiles(a: BehaviorProfile, b: BehaviorProfile): Record<string, {
4
+ from: string;
5
+ to: string;
6
+ }>;
@@ -0,0 +1,46 @@
1
+ function dimLine(label, v) {
2
+ return `- **${label}:** ${v}`;
3
+ }
4
+ const LABELS = {
5
+ changeAppetite: "Change appetite",
6
+ deliberationDepth: "Deliberation depth",
7
+ explanationVerbosity: "Explanation verbosity",
8
+ explorationStyle: "Exploration style",
9
+ ambiguityHandling: "Ambiguity handling",
10
+ checkInFrequency: "Check-in frequency"
11
+ };
12
+ export function summarizeProfileMarkdown(profile) {
13
+ const lines = [
14
+ `## ${profile.label} (\`${profile.id}\`)`,
15
+ "",
16
+ profile.summary,
17
+ "",
18
+ "### Dimensions",
19
+ dimLine(LABELS.changeAppetite, profile.dimensions.changeAppetite),
20
+ dimLine(LABELS.deliberationDepth, profile.dimensions.deliberationDepth),
21
+ dimLine(LABELS.explanationVerbosity, profile.dimensions.explanationVerbosity),
22
+ dimLine(LABELS.explorationStyle, profile.dimensions.explorationStyle),
23
+ dimLine(LABELS.ambiguityHandling, profile.dimensions.ambiguityHandling),
24
+ dimLine(LABELS.checkInFrequency, profile.dimensions.checkInFrequency)
25
+ ];
26
+ if (profile.interactionNotes) {
27
+ lines.push("", "### Interaction notes", "", profile.interactionNotes);
28
+ }
29
+ return lines.join("\n");
30
+ }
31
+ export function diffProfiles(a, b) {
32
+ const diff = {};
33
+ const keys = Object.keys(a.dimensions);
34
+ for (const k of keys) {
35
+ if (a.dimensions[k] !== b.dimensions[k]) {
36
+ diff[k] = { from: a.dimensions[k], to: b.dimensions[k] };
37
+ }
38
+ }
39
+ if (a.label !== b.label) {
40
+ diff.label = { from: a.label, to: b.label };
41
+ }
42
+ if (a.summary !== b.summary) {
43
+ diff.summary = { from: a.summary, to: b.summary };
44
+ }
45
+ return diff;
46
+ }
@@ -0,0 +1,4 @@
1
+ export { BUILTIN_PROFILES, DEFAULT_BUILTIN_PROFILE_ID } from "./builtins.js";
2
+ export { validateBehaviorProfile, mergeDimensions } from "./validate.js";
3
+ import type { WorkflowModule } from "../../contracts/module-contract.js";
4
+ export declare const agentBehaviorModule: WorkflowModule;