@zalom/plastic 2.0.0-alpha.27 → 2.0.0-alpha.28

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 (207) hide show
  1. package/PLASTIC.md +13 -139
  2. package/README.md +337 -133
  3. package/agents/plastic-enforcer.md +9 -10
  4. package/agents/plastic-executor.md +1 -1
  5. package/bin/crap +4 -0
  6. package/bin/lib/context_budget.rb +35 -1
  7. package/bin/lib/skill_census.rb +839 -0
  8. package/bin/plastic +6 -0
  9. package/bin/plastic-skill-census +114 -0
  10. package/bin/verify-change +345 -0
  11. package/deprecations.yml +1 -1
  12. package/{skills/agent-advisor/references → docs/help}/advisor-protocol.md +4 -7
  13. package/{skills/auto/references → docs/help}/agent-architecture.md +7 -7
  14. package/{skills/conventions/references → docs/help}/completion-and-done.md +1 -1
  15. package/{skills/auto/references → docs/help}/human-report-contract.md +17 -19
  16. package/{skills/conventions/references → docs/help}/roadmaps.md +2 -2
  17. package/{skills/tutorial/references → docs/help}/track-1-guided.md +8 -8
  18. package/{skills/tutorial/references → docs/help}/track-2-auto.md +5 -5
  19. package/{skills/tutorial/references → docs/help}/track-3-projects-and-roadmaps.md +24 -17
  20. package/package.json +3 -2
  21. package/scripts/append-ledger +2 -1
  22. package/scripts/dashboard.rb +10 -9
  23. package/scripts/day-summary +2 -1
  24. package/scripts/doctor.rb +48 -42
  25. package/scripts/end-intent +2 -8
  26. package/scripts/file-session-intent +2 -1
  27. package/scripts/hook-capture +4 -3
  28. package/scripts/hook-close +2 -1
  29. package/scripts/hook-record +3 -2
  30. package/scripts/hook-savepoint +3 -2
  31. package/scripts/hook-session-start +5 -4
  32. package/scripts/hook-stop +2 -1
  33. package/scripts/insight-append +1 -2
  34. package/scripts/install.rb +3 -1
  35. package/scripts/lib/active_delivery.rb +1 -1
  36. package/scripts/lib/arm.rb +2 -1
  37. package/scripts/lib/backup.rb +63 -0
  38. package/scripts/lib/cli/command.rb +85 -0
  39. package/scripts/lib/cli/commands/auto.rb +18 -0
  40. package/scripts/lib/cli/commands/auto_brief.rb +44 -0
  41. package/scripts/lib/cli/commands/auto_lock.rb +60 -0
  42. package/scripts/lib/cli/commands/auto_report.rb +50 -0
  43. package/scripts/lib/cli/commands/auto_take.rb +25 -0
  44. package/scripts/lib/cli/commands/backup.rb +43 -0
  45. package/scripts/lib/cli/commands/checkout.rb +25 -0
  46. package/scripts/lib/cli/commands/continue.rb +66 -0
  47. package/scripts/lib/cli/commands/doctor.rb +20 -0
  48. package/scripts/lib/cli/commands/feedback.rb +40 -0
  49. package/scripts/lib/cli/commands/help.rb +69 -0
  50. package/scripts/lib/cli/commands/hook.rb +32 -0
  51. package/scripts/lib/cli/commands/index.rb +23 -0
  52. package/scripts/lib/cli/commands/install.rb +21 -0
  53. package/scripts/lib/cli/commands/installer_verb.rb +37 -0
  54. package/scripts/lib/cli/commands/intent.rb +19 -0
  55. package/scripts/lib/cli/commands/intent_answer.rb +37 -0
  56. package/scripts/lib/cli/commands/intent_command.rb +53 -0
  57. package/scripts/lib/cli/commands/intent_end.rb +61 -0
  58. package/scripts/lib/cli/commands/intent_new.rb +62 -0
  59. package/scripts/lib/cli/commands/intent_note.rb +43 -0
  60. package/scripts/lib/cli/commands/intent_rule.rb +36 -0
  61. package/scripts/lib/cli/commands/intent_show.rb +25 -0
  62. package/scripts/lib/cli/commands/intent_spec.rb +44 -0
  63. package/scripts/lib/cli/commands/intent_step.rb +43 -0
  64. package/scripts/lib/cli/commands/intent_verify.rb +26 -0
  65. package/scripts/lib/cli/commands/migrate.rb +16 -0
  66. package/scripts/lib/cli/commands/migrate_stores.rb +31 -0
  67. package/scripts/lib/cli/commands/next.rb +49 -0
  68. package/scripts/lib/cli/commands/project.rb +19 -0
  69. package/scripts/lib/cli/commands/project_links.rb +42 -0
  70. package/scripts/lib/cli/commands/project_list.rb +20 -0
  71. package/scripts/lib/cli/commands/project_new.rb +72 -0
  72. package/scripts/lib/cli/commands/query.rb +31 -0
  73. package/scripts/lib/cli/commands/render.rb +25 -0
  74. package/scripts/lib/cli/commands/roadmap.rb +19 -0
  75. package/scripts/lib/cli/commands/roadmap_check.rb +44 -0
  76. package/scripts/lib/cli/commands/roadmap_log.rb +54 -0
  77. package/scripts/lib/cli/commands/roadmap_next.rb +34 -0
  78. package/scripts/lib/cli/commands/roadmap_show.rb +45 -0
  79. package/scripts/lib/cli/commands/rollback.rb +20 -0
  80. package/scripts/lib/cli/commands/search.rb +60 -0
  81. package/scripts/lib/cli/commands/session.rb +18 -0
  82. package/scripts/lib/cli/commands/session_commit.rb +42 -0
  83. package/scripts/lib/cli/commands/session_handoff.rb +34 -0
  84. package/scripts/lib/cli/commands/session_summary.rb +35 -0
  85. package/scripts/lib/cli/commands/status.rb +68 -0
  86. package/scripts/lib/cli/commands/subcommand_list.rb +36 -0
  87. package/scripts/lib/cli/commands/sync.rb +46 -0
  88. package/scripts/lib/cli/commands/uninstall.rb +20 -0
  89. package/scripts/lib/cli/commands/update.rb +20 -0
  90. package/scripts/lib/cli/commands/version.rb +53 -0
  91. package/scripts/lib/cli/frontier.rb +84 -0
  92. package/scripts/lib/cli/legacy.rb +50 -0
  93. package/scripts/lib/cli/output.rb +102 -0
  94. package/scripts/lib/cli/scope.rb +127 -0
  95. package/scripts/lib/cli/table.rb +64 -0
  96. package/scripts/lib/cli.rb +94 -0
  97. package/scripts/lib/compact_instructions.rb +8 -0
  98. package/scripts/lib/day_summary.rb +4 -3
  99. package/scripts/lib/doctor_core.rb +7 -32
  100. package/scripts/lib/doctor_session_ledger.rb +2 -1
  101. package/scripts/lib/feedback_report.rb +1 -1
  102. package/scripts/lib/graph_measure_models.rb +3 -1
  103. package/scripts/lib/index_entry.rb +9 -0
  104. package/scripts/lib/installer_core.rb +73 -19
  105. package/scripts/lib/intent_screen.rb +3 -3
  106. package/scripts/lib/lock.rb +2 -2
  107. package/scripts/lib/node_input.rb +3 -2
  108. package/scripts/lib/preflight.rb +2 -4
  109. package/scripts/lib/project_config.rb +2 -1
  110. package/scripts/lib/project_validator.rb +3 -2
  111. package/scripts/lib/qmd_sync.rb +8 -7
  112. package/scripts/lib/reference_archive.rb +45 -0
  113. package/scripts/lib/release_guard.rb +2 -0
  114. package/scripts/lib/report_screen.rb +4 -3
  115. package/scripts/lib/rlm/corpus.rb +13 -0
  116. package/scripts/lib/rlm/probe.rb +29 -0
  117. package/scripts/lib/rlm/query.rb +22 -0
  118. package/scripts/lib/roadmap_queue.rb +2 -2
  119. package/scripts/lib/roadmap_savepoint.rb +1 -1
  120. package/scripts/lib/runner_absorb.rb +3 -2
  121. package/scripts/lib/search_index.rb +55 -0
  122. package/scripts/lib/session_git.rb +4 -3
  123. package/scripts/lib/sqlite.rb +22 -0
  124. package/scripts/lib/store_discovery.rb +7 -6
  125. package/scripts/lib/store_layout.rb +54 -0
  126. package/scripts/lib/store_provisioning.rb +2 -1
  127. package/scripts/lib/store_sync.rb +85 -0
  128. package/scripts/lib/stores_move.rb +93 -0
  129. package/scripts/lib/verify_intent.rb +2 -7
  130. package/scripts/lib/version_number.rb +48 -0
  131. package/scripts/lib/work_graph.rb +59 -0
  132. package/scripts/lib/worktree.rb +3 -8
  133. package/scripts/lib/worktree_sweep.rb +3 -2
  134. package/scripts/link-suggest +2 -1
  135. package/scripts/migrate-to-global +1 -1
  136. package/scripts/new-intent +3 -12
  137. package/scripts/plastic-lock +3 -2
  138. package/scripts/promote-session-item +3 -2
  139. package/scripts/release-check +10 -5
  140. package/scripts/report-screen +1 -1
  141. package/scripts/session-commit +2 -1
  142. package/scripts/spawn-preamble +2 -2
  143. package/scripts/update.rb +25 -4
  144. package/scripts/write-handoff +2 -1
  145. package/templates/agents.md +6 -6
  146. package/templates/render.css +10 -0
  147. package/bin/plastic.js +0 -70
  148. package/skills/agent-advisor/SKILL.md +0 -84
  149. package/skills/auto/SKILL.md +0 -297
  150. package/skills/auto/evals/evals.json +0 -255
  151. package/skills/auto/references/end-tail.md +0 -64
  152. package/skills/conventions/SKILL.md +0 -29
  153. package/skills/dashboard/SKILL.md +0 -180
  154. package/skills/dashboard/evals/evals.json +0 -38
  155. package/skills/dashboard/references/classification.md +0 -22
  156. package/skills/dashboard/templates/dashboard-global.md +0 -20
  157. package/skills/dashboard/templates/dashboard-project.md +0 -19
  158. package/skills/direct/SKILL.md +0 -66
  159. package/skills/direct/references/request-signals.md +0 -59
  160. package/skills/doctor/SKILL.md +0 -305
  161. package/skills/doctor/report.md +0 -102
  162. package/skills/feedback/SKILL.md +0 -98
  163. package/skills/feedback/references/transport-and-privacy.md +0 -65
  164. package/skills/feedback/report.md +0 -36
  165. package/skills/install/SKILL.md +0 -215
  166. package/skills/intent-continuing/SKILL.md +0 -156
  167. package/skills/intent-continuing/references/board-fill.md +0 -52
  168. package/skills/intent-continuing/references/boarding-matrix.md +0 -35
  169. package/skills/intent-continuing/references/context-management.md +0 -28
  170. package/skills/intent-continuing/references/liveness-ranking.md +0 -57
  171. package/skills/intent-creating/SKILL.md +0 -89
  172. package/skills/intent-creating/evals/evals.json +0 -72
  173. package/skills/intent-creating/references/lifecycle.md +0 -81
  174. package/skills/intent-creating/references/wikilinks.md +0 -8
  175. package/skills/intent-ending/SKILL.md +0 -182
  176. package/skills/intent-ending/evals/evals.json +0 -74
  177. package/skills/intent-executing/SKILL.md +0 -87
  178. package/skills/intent-executing/evals/evals.json +0 -66
  179. package/skills/intent-executing/implementer-prompt.md +0 -47
  180. package/skills/intent-executing/spec-reviewer-prompt.md +0 -27
  181. package/skills/intent-speccing/SKILL.md +0 -136
  182. package/skills/intent-speccing/evals/evals.json +0 -126
  183. package/skills/intent-speccing/references/design-principles.md +0 -44
  184. package/skills/intent-speccing/references/per-section-fill-rules.md +0 -92
  185. package/skills/intent-speccing/references/self-verify-checklist.md +0 -37
  186. package/skills/project-creating/SKILL.md +0 -162
  187. package/skills/project-creating/references/hubs-projects.md +0 -55
  188. package/skills/project-creating/references/project-scaffolding.md +0 -97
  189. package/skills/releasing/SKILL.md +0 -376
  190. package/skills/releasing/references/deprecations.md +0 -60
  191. package/skills/releasing/references/promotion-and-tagging.md +0 -70
  192. package/skills/releasing/references/release-lines.md +0 -105
  193. package/skills/roadmap/SKILL.md +0 -90
  194. package/skills/roadmap/references/file-format.md +0 -134
  195. package/skills/roadmap/references/operations.md +0 -112
  196. package/skills/rollback/SKILL.md +0 -91
  197. package/skills/tutorial/SKILL.md +0 -66
  198. package/skills/tutorial/evals/evals.json +0 -186
  199. package/skills/uninstall/SKILL.md +0 -75
  200. package/skills/update/SKILL.md +0 -126
  201. /package/{skills/auto/references → docs/help}/agent-report-contract.md +0 -0
  202. /package/{skills/intent-executing → docs/help}/code-quality-reviewer-prompt.md +0 -0
  203. /package/{skills/conventions/references → docs/help}/knowledge-graph.md +0 -0
  204. /package/{skills/conventions/references → docs/help}/lifecycle-and-savepoints.md +0 -0
  205. /package/{skills/conventions/references → docs/help}/locks-and-worktrees.md +0 -0
  206. /package/{skills/conventions/references → docs/help}/maintenance-and-revisions.md +0 -0
  207. /package/{skills/intent-executing → docs/help}/plan-reviewer-prompt.md +0 -0
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
4
+ require_relative "../legacy"
5
+
6
+ # `plastic feedback "TITLE"` - files a report with feedback-report, the body
7
+ # read from standard input and passed to the child process unchanged.
8
+ module Plastic
9
+ class CLI
10
+ module Commands
11
+ class Feedback < Command
12
+ USAGE_LINE = 'plastic feedback "TITLE"'
13
+
14
+ def initialize(argv, runner: nil, **streams)
15
+ super(argv, **streams)
16
+ @runner = runner
17
+ end
18
+
19
+ def call
20
+ raise Usage, "plastic feedback needs a title" if title.nil? || title.strip.empty?
21
+
22
+ status = legacy.run("feedback-report", "--title", title)
23
+ raise Failure, "feedback-report exited #{status}" unless status.zero?
24
+
25
+ @output.next_step("none", because: "the report is saved as a draft; open the printed URL to send it")
26
+ end
27
+
28
+ private
29
+
30
+ def title
31
+ arguments.first
32
+ end
33
+
34
+ def legacy
35
+ @legacy ||= Legacy.new(env: @env, runner: @runner)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
4
+ require_relative "../table"
5
+
6
+ # `plastic help` - the command list plus the help topics, straight out of the
7
+ # table and docs/help, or one command's usage line, or one topic's chapter. A
8
+ # command name always wins over a topic of the same name. The list loads no
9
+ # command file: that is what the table's summary column is for.
10
+ module Plastic
11
+ class CLI
12
+ module Commands
13
+ class Help < Command
14
+ USAGE_LINE = "plastic help [COMMAND|TOPIC] [--json]"
15
+
16
+ def call
17
+ name = arguments.join(" ")
18
+ return list if name.empty?
19
+ return one_command(name) if TABLE.key?(name)
20
+ return one_topic(name) if topic?(name)
21
+
22
+ raise Usage, "no command or help topic named #{name.inspect}"
23
+ end
24
+
25
+ private
26
+
27
+ def list
28
+ @output.row("usage", "plastic <command> [options]")
29
+ TABLE.sort.each { |name, (_file, _const, summary)| @output.row(name, summary) }
30
+ @output.row("topics", topic_names)
31
+ @output.next_step("plastic status", because: "it needs no argument and names the rest")
32
+ end
33
+
34
+ def one_command(name)
35
+ file, const, summary = TABLE.fetch(name)
36
+ require_relative "../#{file}"
37
+ @output.row("usage", Commands.const_get(const)::USAGE_LINE)
38
+ @output.row("summary", summary)
39
+ @output.next_step("none", because: "the usage line is the whole answer")
40
+ end
41
+
42
+ def one_topic(name)
43
+ @output.row(name, File.read(topic_path(name)))
44
+ @output.next_step("none", because: "the chapter is the whole answer")
45
+ end
46
+
47
+ def topic?(name)
48
+ name == File.basename(name) && File.file?(topic_path(name))
49
+ end
50
+
51
+ def topic_names
52
+ Dir.glob(File.join(help_dir, "*.md")).map { |path| File.basename(path, ".md") }.sort
53
+ end
54
+
55
+ def topic_path(name)
56
+ File.join(help_dir, "#{name}.md")
57
+ end
58
+
59
+ def help_dir
60
+ File.join(package_root, "docs", "help")
61
+ end
62
+
63
+ def package_root
64
+ @env["PLASTIC_PACKAGE_ROOT"] || File.expand_path("../../../..", __dir__)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "English"
4
+ require_relative "../command"
5
+ require_relative "../legacy"
6
+
7
+ module Plastic
8
+ class CLI
9
+ module Commands
10
+ class Hook < Command
11
+ USAGE_LINE = "plastic hook EVENT"
12
+ EVENTS = %w[call-budget capture close record savepoint session-start stop].freeze
13
+
14
+ DEFAULT_RUNNER = lambda do |path|
15
+ system(path)
16
+ Legacy.exit_code($CHILD_STATUS)
17
+ end
18
+
19
+ def self.call(argv, runner: DEFAULT_RUNNER, **seams)
20
+ return super(argv, **seams) unless EVENTS.include?(argv.first)
21
+
22
+ root = Legacy.new(env: seams.fetch(:env, ENV)).package_root
23
+ runner.call(File.join(root, "hooks", argv.first))
24
+ end
25
+
26
+ def call
27
+ raise Usage, "EVENT is one of #{EVENTS.join(", ")}"
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
4
+ require_relative "../../search_index"
5
+
6
+ module Plastic
7
+ class CLI
8
+ module Commands
9
+ class Index < Command
10
+ USAGE_LINE = "plastic index [--json]"
11
+
12
+ def call
13
+ count = SearchIndex.build(scope.plastic_home)
14
+ @output.row("indexed", "#{count} files")
15
+ @output.row("database", SearchIndex.path(scope.plastic_home))
16
+ @output.next_step("plastic search TERMS", because: "the index is whole and new; it is rebuilt, never updated")
17
+ rescue Sqlite::Error => e
18
+ raise Failure, e.message
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "installer_verb"
4
+
5
+ # `plastic install` - wires Plastic into this machine's agents. The work is
6
+ # still scripts/install.rb, run as a child process through Legacy; this command
7
+ # is what replaces the Node shim the npm package used to carry.
8
+ module Plastic
9
+ class CLI
10
+ module Commands
11
+ class Install < InstallerVerb
12
+ USAGE_LINE = "plastic install [--claude] [--codex] [--hermes] [--all] [--reinstall] [--force] [--advisor NAME] [--no-advisor] [--statusline]"
13
+ FLAGS = %w[--claude --codex --hermes --all --reinstall --force --advisor --no-advisor --statusline].freeze
14
+
15
+ SCRIPT = "install.rb"
16
+ AFTER = "plastic version"
17
+ BECAUSE = "the install is done, and the version proves the command works"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
4
+ require_relative "../legacy"
5
+
6
+ module Plastic
7
+ class CLI
8
+ module Commands
9
+ class InstallerVerb < Command
10
+ def initialize(argv, runner: nil, **streams)
11
+ super(argv, **streams)
12
+ @runner = runner
13
+ end
14
+
15
+ def call
16
+ unknown = arguments.grep(/\A-/) - self.class::FLAGS
17
+ raise Usage, "#{unknown.first} is not a flag of this command" unless unknown.empty?
18
+
19
+ status = legacy.run(self.class::SCRIPT, *arguments)
20
+ raise Failure, "#{self.class::SCRIPT} exited #{status}" unless status.zero?
21
+
22
+ @output.next_step(self.class::AFTER, because: self.class::BECAUSE)
23
+ end
24
+
25
+ private
26
+
27
+ def options
28
+ @options ||= {}
29
+ end
30
+
31
+ def legacy
32
+ @legacy ||= Legacy.new(env: @env, runner: @runner)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "subcommand_list"
4
+
5
+ # `plastic intent` - the list of `plastic intent ...` subcommands, straight out
6
+ # of the table; a word that names none of them is a usage error naming the
7
+ # same list, so a typo never falls through to a script.
8
+ module Plastic
9
+ class CLI
10
+ module Commands
11
+ class Intent < SubcommandList
12
+ USAGE_LINE = "plastic intent SUBCOMMAND [options]"
13
+ PREFIX = "intent"
14
+ NEXT = "plastic intent show ID"
15
+ BECAUSE = "an id is the one thing every other subcommand needs"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "intent_command"
4
+
5
+ # `plastic intent answer` - closes a `needs_decision` node with the owner's
6
+ # ruling (`runner answer`, run through Legacy).
7
+ module Plastic
8
+ class CLI
9
+ module Commands
10
+ class IntentAnswer < IntentCommand
11
+ USAGE_LINE = 'plastic intent answer ID --node NODE --decision "TEXT" [--json]'
12
+
13
+ SCRIPT = "runner"
14
+ AFTER = "plastic intent step ID"
15
+ BECAUSE = "step resumes the graph past the node this decision just closed"
16
+
17
+ def call
18
+ raise Usage, "--node is required" if options[:node].to_s.empty?
19
+ raise Usage, "--decision is required" if options[:decision].to_s.empty?
20
+
21
+ super
22
+ end
23
+
24
+ private
25
+
26
+ def switches(parser)
27
+ parser.on("--node ID") { |v| @options[:node] = v }
28
+ parser.on("--decision TEXT") { |v| @options[:decision] = v }
29
+ end
30
+
31
+ def script_arguments
32
+ ["answer", intent_dir, "--node", options[:node], "--answer", options[:decision]]
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
4
+ require_relative "../legacy"
5
+
6
+ # Plastic::CLI::Commands::IntentCommand (intent 372, family 2) - the shared
7
+ # base every `plastic intent ...` subcommand runs on: it turns the positional
8
+ # id into an intent directory through Scope, runs the one script the
9
+ # subclass names, and prints the `next:`/`because:` trailer the plan calls
10
+ # for. A subcommand that needs more than that (extra usage checks, printed
11
+ # guidance, a different script-exit contract) overrides `call`.
12
+ module Plastic
13
+ class CLI
14
+ module Commands
15
+ class IntentCommand < Command
16
+ def initialize(argv, runner: nil, **streams)
17
+ super(argv, **streams)
18
+ @runner = runner
19
+ end
20
+
21
+ def call
22
+ status = legacy.run(self.class::SCRIPT, *script_arguments)
23
+ raise Failure, "#{self.class::SCRIPT} exited #{status}" unless status.zero?
24
+
25
+ @output.next_step(self.class::AFTER.sub("ID", id.to_s), because: self.class::BECAUSE)
26
+ end
27
+
28
+ private
29
+
30
+ def id
31
+ arguments.first
32
+ end
33
+
34
+ def intent_dir
35
+ return @intent_dir if defined?(@intent_dir)
36
+
37
+ @intent_dir = scope.intent_dir(id)
38
+ return @intent_dir if @intent_dir
39
+
40
+ raise Failure, "no intent #{id.inspect} in #{scope.slug}; plastic status lists the ones that exist"
41
+ end
42
+
43
+ def legacy
44
+ @legacy ||= Legacy.new(env: @env, runner: @runner)
45
+ end
46
+
47
+ def script_arguments
48
+ raise NoMethodError, "#{self.class} must define script_arguments"
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "intent_command"
4
+
5
+ # `plastic intent end` - closes an intent as delivered or abandoned
6
+ # (`end-intent`, run through Legacy). end-intent's own exit code 4 is a
7
+ # pre-flight refusal (a live foreign session holds the delivery lock), not
8
+ # the exit 3 Legacy's generic contract turns into a Refusal on its own, so
9
+ # this command maps it by hand rather than through Legacy#run.
10
+ module Plastic
11
+ class CLI
12
+ module Commands
13
+ class IntentEnd < IntentCommand
14
+ USAGE_LINE = 'plastic intent end ID --delivered|--abandoned --summary "TEXT" [--note "TEXT"] [--dry-run] [--json]'
15
+
16
+ REFUSAL_STATUS = 4
17
+
18
+ SUMMARY_GUIDANCE = [
19
+ "a good summary is written for the reader deciding whether to merge, release, or accept",
20
+ "delivered: what shipped, impact and risk first, in plain language, never the checklist",
21
+ "abandoned: why, and the trail if part of the work was dropped mid-flight"
22
+ ].freeze
23
+
24
+ def call
25
+ raise Usage, "one of --delivered or --abandoned is required" unless disposition
26
+ raise Usage, SUMMARY_GUIDANCE.join("\n") if options[:summary].to_s.empty?
27
+
28
+ status = legacy.run("end-intent", *end_intent_arguments)
29
+ raise Refusal, "end-intent needs the owner: the delivery lock is held" if status == REFUSAL_STATUS
30
+ raise Failure, "end-intent exited #{status}" unless status.zero?
31
+
32
+ @output.next_step("plastic status", because: "the intent moved out of Active")
33
+ end
34
+
35
+ private
36
+
37
+ def disposition
38
+ return "delivered" if options[:delivered]
39
+ "abandoned" if options[:abandoned]
40
+ end
41
+
42
+ def switches(parser)
43
+ parser.on("--delivered") { @options[:delivered] = true }
44
+ parser.on("--abandoned") { @options[:abandoned] = true }
45
+ parser.on("--summary TEXT") { |v| @options[:summary] = v }
46
+ parser.on("--note TEXT") { |v| @options[:note] = v }
47
+ parser.on("--dry-run") { @options[:dry_run] = true }
48
+ end
49
+
50
+ def end_intent_arguments
51
+ intent_dir
52
+ args = ["--store", scope.store, "--id", id, "--disposition", disposition,
53
+ "--outcome-summary", options[:summary]]
54
+ args += ["--index-note", options[:note]] if options[:note]
55
+ args << "--dry-run" if options[:dry_run]
56
+ args
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
4
+ require_relative "../legacy"
5
+ require_relative "../../index_entry"
6
+
7
+ module Plastic
8
+ class CLI
9
+ module Commands
10
+ class IntentNew < Command
11
+ USAGE_LINE = 'plastic intent new "LINE" [--slug SLUG] [--parent ID] [--sources IDS] [--tags TAGS] [--json]'
12
+ PASSED_THROUGH = %i[parent sources tags].freeze
13
+
14
+ def initialize(argv, runner: nil, **streams)
15
+ super(argv, **streams)
16
+ @runner = runner
17
+ end
18
+
19
+ def call
20
+ raise Usage, "the one-line intent statement is required" if line.to_s.empty?
21
+
22
+ status = Legacy.new(env: @env, runner: @runner).run("new-intent", *new_intent_arguments)
23
+ raise Failure, "new-intent exited #{status}" unless status.zero?
24
+
25
+ IndexEntry.add_active(scope.index_path, dir_name: dir_name, title: line)
26
+ @output.next_step("plastic intent spec #{id}", because: "a new intent has no specification yet")
27
+ end
28
+
29
+ private
30
+
31
+ def line
32
+ arguments.first
33
+ end
34
+
35
+ def slug
36
+ options[:slug] || line.downcase.scan(/[a-z0-9]+/).first(5).join("-")
37
+ end
38
+
39
+ def dir_name
40
+ newest = Dir.glob(File.join(scope.store, "*--#{slug}")).max_by { |path| File.mtime(path) }
41
+ raise Failure, "new-intent made no directory for #{slug}" unless newest
42
+
43
+ File.basename(newest)
44
+ end
45
+
46
+ def id
47
+ dir_name.split("--").first
48
+ end
49
+
50
+ def switches(parser)
51
+ parser.on("--slug SLUG") { |v| @options[:slug] = v }
52
+ PASSED_THROUGH.each { |key| parser.on("--#{key} VALUE") { |v| @options[key] = v } }
53
+ end
54
+
55
+ def new_intent_arguments
56
+ given = PASSED_THROUGH.select { |key| options[key] }
57
+ ["--store", scope.store, "--intent", line, "--slug", slug] + given.flat_map { |key| ["--#{key}", options[key]] }
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "intent_command"
4
+
5
+ # `plastic intent note` - appends a savepoint line to an intent
6
+ # (`savepoint-note`, run through Legacy). `--kind` defaults to Report, the
7
+ # most general of the three savepoint kinds, for a note that names no kind
8
+ # of its own.
9
+ module Plastic
10
+ class CLI
11
+ module Commands
12
+ class IntentNote < IntentCommand
13
+ USAGE_LINE = 'plastic intent note ID "TEXT" [--kind Review|Commit|Report] [--json]'
14
+
15
+ SCRIPT = "savepoint-note"
16
+ AFTER = "plastic intent show ID"
17
+ BECAUSE = "the state screen carries the savepoint trail this just wrote"
18
+
19
+ DEFAULT_KIND = "Report"
20
+
21
+ def call
22
+ raise Usage, "the note text is required" if text.to_s.empty?
23
+
24
+ super
25
+ end
26
+
27
+ private
28
+
29
+ def text
30
+ arguments[1]
31
+ end
32
+
33
+ def switches(parser)
34
+ parser.on("--kind KIND") { |v| @options[:kind] = v }
35
+ end
36
+
37
+ def script_arguments
38
+ [intent_dir, "--kind", options[:kind] || DEFAULT_KIND, "--text", text]
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "intent_command"
4
+
5
+ # `plastic intent rule` - records one ruling in an intent's `## Insights`
6
+ # (`insight-append`, run through Legacy, stamped `--stage Why --author human`
7
+ # since a rule is always the owner's).
8
+ module Plastic
9
+ class CLI
10
+ module Commands
11
+ class IntentRule < IntentCommand
12
+ USAGE_LINE = 'plastic intent rule ID "TEXT" [--json]'
13
+
14
+ SCRIPT = "insight-append"
15
+ AFTER = "plastic intent show ID"
16
+ BECAUSE = "the state screen reads Insights straight off the ledger this just wrote"
17
+
18
+ def call
19
+ raise Usage, "the ruling text is required" if text.to_s.empty?
20
+
21
+ super
22
+ end
23
+
24
+ private
25
+
26
+ def text
27
+ arguments[1]
28
+ end
29
+
30
+ def script_arguments
31
+ [intent_dir, text, "--stage", "Why", "--author", "human"]
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "intent_command"
4
+
5
+ # `plastic intent show` - an intent's state screen (`report-screen state`, run
6
+ # through Legacy).
7
+ module Plastic
8
+ class CLI
9
+ module Commands
10
+ class IntentShow < IntentCommand
11
+ USAGE_LINE = "plastic intent show ID [--json]"
12
+
13
+ SCRIPT = "report-screen"
14
+ AFTER = "plastic intent step ID"
15
+ BECAUSE = "the state screen is where the next step comes from"
16
+
17
+ private
18
+
19
+ def script_arguments
20
+ ["state", intent_dir]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "intent_command"
4
+
5
+ # `plastic intent spec` - an intent's state screen (`report-screen state`,
6
+ # same as `plastic intent show`), then the five rules the speccing
7
+ # conversation itself runs on, so the reply carries both without a second
8
+ # call.
9
+ module Plastic
10
+ class CLI
11
+ module Commands
12
+ class IntentSpec < IntentCommand
13
+ USAGE_LINE = "plastic intent spec ID [--json]"
14
+
15
+ SCRIPT = "report-screen"
16
+ AFTER = 'plastic intent rule ID "TEXT"'
17
+ BECAUSE = "a ruling is recorded the moment it lands, never batched"
18
+
19
+ RULES = [
20
+ "1. context first: read the project state and the intent's Context and Insights",
21
+ "2. assess scope: several independent subsystems become separate thinking conversations",
22
+ "3. one question per message, in prose; look at the code before asking how something works",
23
+ "4. propose two or three approaches, trade-offs first, leading with the recommendation",
24
+ "5. present the design in sections scaled to complexity; get a ruling after each section",
25
+ "6. record every ruling the instant it lands, never batched:",
26
+ ' plastic intent rule ID "<ruling text>"',
27
+ "7. a later ruling that conflicts with an earlier one gets a new insight naming it superseded",
28
+ "8. both rulings stay on record; the later one wins"
29
+ ].freeze
30
+
31
+ def call
32
+ super
33
+ @output.row("rules", RULES)
34
+ end
35
+
36
+ private
37
+
38
+ def script_arguments
39
+ ["state", intent_dir]
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "intent_command"
4
+
5
+ # `plastic intent step` - runs the graph's next ready step (`runner step`, run
6
+ # through Legacy). An intent with no `graph.md` gets the four-line non-graph
7
+ # procedure printed alongside it, since there is no graph for `step` itself
8
+ # to drive.
9
+ module Plastic
10
+ class CLI
11
+ module Commands
12
+ class IntentStep < IntentCommand
13
+ USAGE_LINE = "plastic intent step ID [--json]"
14
+
15
+ SCRIPT = "runner"
16
+ AFTER = "plastic intent step ID"
17
+ BECAUSE = "call step again after each dispatched node returns"
18
+
19
+ NON_GRAPH_WORK = [
20
+ "no graph.md: dispatch ONE plastic-executor subagent with the whole consolidated action pasted in, never a file reference",
21
+ "it writes the matrix's tests and commits them red, implements the action in order, and drives the suite green",
22
+ "a tick is two edits made together: mark the item's box [x], and move it from ## In Progress to ## Completed",
23
+ "add one ## Session Log row per tick; never batch several tasks into one later edit"
24
+ ].freeze
25
+
26
+ def call
27
+ super
28
+ @output.row("non-graph work", NON_GRAPH_WORK) unless graph?
29
+ end
30
+
31
+ private
32
+
33
+ def graph?
34
+ File.exist?(File.join(intent_dir, "graph.md"))
35
+ end
36
+
37
+ def script_arguments
38
+ ["step", intent_dir]
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "intent_command"
4
+
5
+ # `plastic intent verify` - the merge-gate checks one intent needs before a
6
+ # close is trustworthy (`verify-intent`, run through Legacy).
7
+ module Plastic
8
+ class CLI
9
+ module Commands
10
+ class IntentVerify < IntentCommand
11
+ USAGE_LINE = "plastic intent verify ID [--json]"
12
+
13
+ SCRIPT = "verify-intent"
14
+ AFTER = 'plastic intent end ID --delivered --summary "TEXT"'
15
+ BECAUSE = "a clean verify is what makes the close trustworthy"
16
+
17
+ private
18
+
19
+ def script_arguments
20
+ intent_dir
21
+ ["--store", scope.store, "--id", id]
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end