@brainervirus/workit-core 0.6.1 → 0.7.1

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 (81) hide show
  1. package/package.json +3 -7
  2. package/scripts/doctor-check.ts +20 -0
  3. package/scripts/install-cursor-plugin.sh +51 -28
  4. package/scripts/install-opencode-plugin.sh +19 -21
  5. package/scripts/rewrite-workspace-deps.ts +15 -9
  6. package/scripts/sync-runtime.sh +71 -19
  7. package/scripts/vendor-assets.ts +37 -0
  8. package/skills/wk-implement/SKILL.md +2 -2
  9. package/skills/wk-pr/SKILL.md +1 -1
  10. package/src/core/boundary.ts +27 -0
  11. package/src/core/branch-policy.ts +63 -0
  12. package/src/core/branch.ts +30 -16
  13. package/src/core/config.ts +193 -31
  14. package/src/core/docs-layout.ts +251 -0
  15. package/src/core/docs-migration.ts +639 -0
  16. package/src/core/docs-repo.ts +11 -9
  17. package/src/core/docs-validate.ts +18 -6
  18. package/src/core/doctor.ts +801 -0
  19. package/src/core/flow-state.ts +1579 -141
  20. package/src/core/git.ts +22 -5
  21. package/src/{tools/handoff.ts → core/handoff-tools.ts} +5 -57
  22. package/src/core/hygiene.ts +26 -12
  23. package/src/core/init.ts +43 -11
  24. package/src/core/logger.ts +321 -0
  25. package/src/core/package-root.ts +28 -0
  26. package/src/core/ports/init-toolkit-status.ts +1 -1
  27. package/src/core/ports/vcs-verify-token.ts +1 -1
  28. package/src/core/ports/youtrack-api.ts +1 -1
  29. package/src/core/ports/youtrack-verify-token.ts +1 -1
  30. package/src/core/pr-create.ts +116 -21
  31. package/src/core/registration.ts +215 -0
  32. package/src/core/repo-context.ts +447 -0
  33. package/src/core/repo-tools.ts +23 -0
  34. package/src/core/safe-write.ts +22 -0
  35. package/src/core/scripts.ts +3 -44
  36. package/src/core/sdd.ts +45 -28
  37. package/src/core/setup-state.ts +54 -0
  38. package/src/core/setup.ts +1216 -0
  39. package/src/core/skill-manifests.ts +95 -0
  40. package/src/core/support-matrix.ts +12 -0
  41. package/src/core/sync-runtime.ts +348 -0
  42. package/src/core/templates.ts +2 -2
  43. package/src/core/vcs-config.ts +107 -37
  44. package/src/core/verify-project.ts +181 -0
  45. package/src/core/workspaces.ts +136 -17
  46. package/src/core/youtrack-tools.ts +228 -0
  47. package/src/core/youtrack.ts +125 -67
  48. package/templates/execution-contract.md +9 -7
  49. package/templates/superpowers-doc-contract.md +4 -3
  50. package/scripts/_shared/common.sh +0 -173
  51. package/scripts/changelog-context.sh +0 -42
  52. package/scripts/docs-refresh-context.sh +0 -40
  53. package/scripts/init/apply.sh +0 -5
  54. package/scripts/init/status.sh +0 -5
  55. package/scripts/init/toolkit-status.sh +0 -5
  56. package/scripts/pr-create.sh +0 -5
  57. package/scripts/pr-ready-context.sh +0 -88
  58. package/scripts/present/ascii-wireframe.sh +0 -5
  59. package/scripts/present/flow-diagram.sh +0 -5
  60. package/scripts/release-notes-context.sh +0 -40
  61. package/scripts/vcs/config.sh +0 -5
  62. package/scripts/vcs/merged-style.sh +0 -5
  63. package/scripts/vcs/token-create-urls.sh +0 -5
  64. package/scripts/vcs/verify-token.sh +0 -5
  65. package/scripts/verify-project.sh +0 -140
  66. package/scripts/youtrack/api.sh +0 -5
  67. package/scripts/youtrack/config.sh +0 -5
  68. package/scripts/youtrack/greeting.sh +0 -5
  69. package/scripts/youtrack/parse-duration.sh +0 -5
  70. package/scripts/youtrack/token-create-url.sh +0 -5
  71. package/scripts/youtrack/verify-token.sh +0 -5
  72. package/scripts/youtrack/work-date-ms.sh +0 -5
  73. package/src/tools/docs-repo.ts +0 -51
  74. package/src/tools/flow.ts +0 -99
  75. package/src/tools/index.ts +0 -22
  76. package/src/tools/present.ts +0 -49
  77. package/src/tools/repo.ts +0 -490
  78. package/src/tools/rules.ts +0 -30
  79. package/src/tools/sdd.ts +0 -216
  80. package/src/tools/templates.ts +0 -27
  81. package/src/tools/youtrack.ts +0 -423
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
2
2
  import { hygieneFiles } from "./hygiene";
3
3
  import { execFileSync } from "node:child_process";
4
4
  import path from "node:path";
5
+ import { resolveCanonicalLayout, resolveDocsPath } from "./docs-layout";
5
6
 
6
7
  export type DocError = { code: string; message: string; path?: string };
7
8
 
@@ -107,9 +108,15 @@ export const docsValidate = ({
107
108
  quality: QualityFinding[];
108
109
  }
109
110
  | { ok: false; errors: DocError[]; error: string } => {
110
- const cwd = path.resolve(workspace_root);
111
- const specAbs = path.isAbsolute(spec_path) ? spec_path : path.join(cwd, spec_path);
112
- const planAbs = path.isAbsolute(plan_path) ? plan_path : path.join(cwd, plan_path);
111
+ // One shared contained path contract (DC-01, DC-02): absolute/traversal/
112
+ // symlink-escape/cross-slug/wrong-basename/legacy paths all fail here before
113
+ // any document bytes are read.
114
+ const resolved = resolveCanonicalLayout({ workspace_root, spec_path, plan_path });
115
+ if (!resolved.ok) return failValidate([err("path_contract", resolved.error)]);
116
+ const cwd = resolved.layout.workspace;
117
+ const specAbs = resolved.layout.spec;
118
+ const planAbs = resolved.layout.plan;
119
+ const slug = resolved.layout.slug;
113
120
  const errors: DocError[] = [];
114
121
 
115
122
  const read = (p: string): string | null => {
@@ -138,8 +145,14 @@ export const docsValidate = ({
138
145
  errors.push(err("missing_spec_link", "**Spec:** link required in plan", plan_path));
139
146
  } else {
140
147
  const linked = (linkMatch[1] ?? linkMatch[2] ?? "").trim();
141
- const linkedAbs = path.isAbsolute(linked) ? linked : path.join(cwd, linked);
142
- if (path.resolve(linkedAbs) !== path.resolve(specAbs)) {
148
+ // The plan link is a path inside the workspace docs tree: canonicalize it
149
+ // under the same contained contract before comparing to the canonical spec.
150
+ const linkedResolved = resolveDocsPath({ workspace_root: cwd, path: linked });
151
+ if (!linkedResolved.ok) {
152
+ errors.push(
153
+ err("spec_link_escape", `plan **Spec:** ${linked} is not a contained docs path`, plan_path),
154
+ );
155
+ } else if (linkedResolved.path !== specAbs) {
143
156
  errors.push(
144
157
  err(
145
158
  "spec_mismatch",
@@ -189,7 +202,6 @@ export const docsValidate = ({
189
202
  const relSpec = path.isAbsolute(spec_path) ? path.relative(cwd, specAbs) : spec_path;
190
203
  const relPlan = path.isAbsolute(plan_path) ? path.relative(cwd, planAbs) : plan_path;
191
204
  const quality = qualitySpec(specText!);
192
- const slug = path.basename(path.dirname(spec_path));
193
205
  if (!sddIgnored(cwd, slug)) {
194
206
  quality.push({
195
207
  code: "sdd_not_ignored",